Cody

# Problem 45474. Sub-sequence - 02

Solution 2232971

Submitted on 24 Apr 2020 by William
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
a=[1,1,1,1,1,2,3,1,4] b=[2,3,0,0,9,5,4,1] assert(isequal(longest_sub_common(a,b),3))

a = 1 1 1 1 1 2 3 1 4 b = 2 3 0 0 9 5 4 1

2   Pass
a=[1,1,1,1,1,2,3] b=[2,3,0,0,9,5,4,1] assert(isequal(longest_sub_common(a,b),2))

a = 1 1 1 1 1 2 3 b = 2 3 0 0 9 5 4 1

3   Pass
a=[1,1,1,1,1,2,3,1,4] b=zeros(1,500); assert(isequal(longest_sub_common(a,b),0))

a = 1 1 1 1 1 2 3 1 4

4   Pass
a=[1,1,1,1,1,2,3,1,4] b=[zeros(1,50),ones(1,200),ones(1,20)*3] assert(isequal(longest_sub_common(a,b),6))

a = 1 1 1 1 1 2 3 1 4 b = Columns 1 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 Columns 61 through 90 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 91 through 120 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 121 through 150 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 151 through 180 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 181 through 210 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 211 through 240 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 241 through 270 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

5   Pass
a='aaabbbcccxyz' b='abcyycbaabc' assert(isequal(longest_sub_common(a,b),5))

a = 'aaabbbcccxyz' b = 'abcyycbaabc'

6   Pass
a=[10 9 8 2 4 2 1 4 7 7 6 5 3 6 8 8 6 8 7 2 6 4 1 2 2 7 5 7 3 1 6 3 10 10 4 1 7 9 10 1 5 6 7 8 7 8 4 6 2 1 10 3 6 10 2 2 4 10 4 3 2 4 4 2 5 1 7 1 6 8 3 5 6 1 5 7 3 9 10 9 6 3 8 3 10 7 7 2 1 3 9 10 7 8 3 6 9 5 10 1 4 6 1 8 6 6 9 9 8 4 5 8 2 2 3 6 10 8 4 3 9 10 7 3 1 9 6 10 1 6 3 9 2 5 4 9 7 3 4 2 7 6 2 2 5 10 6 1 1 9 5 4 8 4 6 8 9 4 7 10 1 6 5 4 3 8 10 2 8 2 10 9 5 8 5 9 4 1 6 10 2 5 8 1 10 8 6 2 5 6 10 9 10 7 5 10 5 3 4 8 6 8 10 10 6 10 2 1 4 6 6 10 6 5 6 8 1 9 2 5 3 4 7 2 3 2 2 4 9 5 5 2 10 5 9 7 4 9 8 5 9 9 5 4 6 10 8 4 8 10 6 6 4 1 2 1 5 1 10 7 1 1 3 5 2 1 8 4 8 5 5 1 1 1 6 3 9 9 10 5 3 3 6 8 4 5 7 10 2 8 6 5 9 4 2 7 7 4 9 10 10 2 3 1 7 2 5 9 6 4 3 5 10 2 5 9 1 7 10 3 2 7 10 7 9 2 8 4 5 2 9 7 8 9 1 10 5 8 8 9 2 5 7 10 9 9 6 6 9 1 9 5 1 8 2 2 7 3 4 5 5 4 7 2 2 1 4 8 3 8 7 9 9 3 4 6 4 9 9 6 3 7 3 5 4 6 10 8 10 3 6 1 8 7 9 10 10 5 1 6 3 3 4 1 8 8 6 4 9 6 10 9 4 6 4 7 8 8 2 9 1 5 8 8 4 8 9 3 2 3 4 3 10 1 6 2 9 2 6 10 4 1 3 4 4 3 10 7 10 5 10 1 7 9 3 10 8 9 6 8 4 3 4 6 9 3 5 9 7 10 3 9 7 3 5 4 6 9 2 9 9 4 5 6 8 8 8 4 5 10 6 9 3 7 6 10 1 6 6 1] b=[14 14 7 12 3 10 4 7 13 3 5 8 6 12 15 3 4 11 6 15 15 10 13 7 10 15 9 15 11 8 10 14 3 6 15 7 10 14 15 10 2 1 10 9 15 12 10 8 4 15 9 1 11 8 1 14 5 4 2 5 4 10 1 5 5 14 7 12 10 12 2 15 13 1 7 5 10 4 9 10 9 7 1 8 7 2 7 7 9 13 11 14 1 4 7 15 12 7 6 1 12 8 3 7 3 12 6 15 1 13 10 9 10 11 2 14 1 5 3 14 2 9 10 10 13 1 13 8 11 4 9 11 15 7 2 1 10 12 11 6 15 8 15 2 4 12 14 12 5 3 13 12 5 4 5 13 13 9 9 5 11 12 7 7 7 5 11 14 14 12 4 11 2 2 3 3 9 2 13 11 14 8 10 14 9 5 15 1 5 15 6 5 2 14 3 5 14 8 10 9 11 1 8 1 13 6 13 4 9 15 1 1 1 11 9 2 12 10 2 2 3 12 2 4 4 2 13 11 12 10 8 5 10 2 3 1 15 15 2 8 10 5 12 9 7 5 12 14 11 7] assert(isequal(longest_sub_common(a,b),121))

a = Columns 1 through 30 10 9 8 2 4 2 1 4 7 7 6 5 3 6 8 8 6 8 7 2 6 4 1 2 2 7 5 7 3 1 Columns 31 through 60 6 3 10 10 4 1 7 9 10 1 5 6 7 8 7 8 4 6 2 1 10 3 6 10 2 2 4 10 4 3 Columns 61 through 90 2 4 4 2 5 1 7 1 6 8 3 5 6 1 5 7 3 9 10 9 6 3 8 3 10 7 7 2 1 3 Columns 91 through 120 9 10 7 8 3 6 9 5 10 1 4 6 1 8 6 6 9 9 8 4 5 8 2 2 3 6 10 8 4 3 Columns 121 through 150 9 10 7 3 1 9 6 10 1 6 3 9 2 5 4 9 7 3 4 2 7 6 2 2 5 10 6 1 1 9 Columns 151 through 180 5 4 8 4 6 8 9 4 7 10 1 6 5 4 3 8 10 2 8 2 10 9 5 8 5 9 4 1 6 10 Columns 181 through 210 2 5 8 1 10 8 6 2 5 6 10 9 10 7 5 10 5 3 4 8 6 8 10 10 6 10 2 1 4 6 Columns 211 through 240 6 10 6 5 6 8 1 9 2 5 3 4 7 2 3 2 2 4 9 5 5 2 10 5 9 7 4 9 8 5 Columns 241 through 270 9 9 5 4 6 10 8 4 8 10 6 6 4 1 2 1 5 1 10 7 1 1 3 5 2 1 8 4 8 5 Columns 271 through 300 5 1 1 1 6 3 9 9 10 5 3 3 6 8 4 5 7 10 2 8 6 5 9 4 2 7 7 4 9 10 Columns 301 through 330 10 2 3 1 7 2 5 9 6 4 3 5 10 2 5 9 1 7 10 3 2 7 10 7 9 2 8 4 5 2 Columns 331 through 360 9 7 8 9 1 10 5 8 8 9 2 5 7 10 9 9 6 6 9 1 9 5 1 8 2 2 7 3 4 5 Columns 361 through 390 5 4 7 2 2 1 4 8 3 8 7 9 9 3 4 6 4 9 9 6 3 7 3 5 4 6 10 8 10 3 Columns 391 through 420 6 1 8 7 9 10 10 5 1 6 3 3 4 1 8 8 6 4 9 6 10 9 4 6 4 7 8 8 2 9 Columns 421 through 450 1 5 8 8 4 8 9 3 2 3 4 3 10 1 6 2 9 2 6 10 4 1 3 4 4 3 10 7 10 5 Columns 451 through 480 10 1 7 9 3 10 8 9 6 8 4 3 4 6 9 3 5 9 7 10 3 9 7 3 5 4 6 9 2 9 Columns 481 through 500 9 4 5 6 8 8 8 4 5 10 6 9 3 7 6 10 1 6 6 1 b = Columns 1 through 30 14 14 7 12 3 10 4 7 13 3 5 8 6 12 15 3 4 11 6 15 15 10 13 7 10 15 9 15 11 8 Columns 31 through 60 10 14 3 6 15 7 10 14 15 10 2 1 10 9 15 12 10 8 4 15 9 1 11 8 1 14 5 4 2 5 Columns 61 through 90 4 10 1 5 5 14 7 12 10 12 2 15 13 1 7 5 10 4 9 10 9 7 1 8 7 2 7 7 9 13 Columns 91 through 120 11 14 1 4 7 15 12 7 6 1 12 8 3 7 3 12 6 15 1 13 10 9 10 11 2 14 1 5 3 14 Columns 121 through 150 2 9 10 10 13 1 13 8 11 4 9 11 15 7 2 1 10 12 11 6 15 8 15 2 4 12 14 12 5 3 Columns 151 through 180 13 12 5 4 5 13 13 9 9 5 11 12 7 7 7 5 11 14 14 12 4 11 2 2 3 3 9 2 13 11 Columns 181 through 210 14 8 10 14 9 5 15 1 5 15 6 5 2 14 3 5 14 8 10 9 11 1 8 1 13 6 13 4 9 15 Columns 211 through 240 1 1 1 11 9 2 12 10 2 2 3 12 2 4 4 2 13 11 12 10 8 5 10 2 3 1 15 15 2 8 Columns 241 through 250 10 5 12 9 7 5 12 14 11 7

7   Pass
a='aaabaaabaaabaaa' b='abababababa' assert(isequal(longest_sub_common(a,b),9))

a = 'aaabaaabaaabaaa' b = 'abababababa'