Cody

Problem 45475. Sub-sequence - 03

Solution 2234597

Submitted on 25 Apr 2020 by bainhome
  • Size: 133
  • This is the leading solution.
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] c=[10,10,9,9,4,4,5] assert(isequal(longest_sub_common_3d(a,b,c),1))

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

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

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

3   Pass
a=' arthur' b='ser arthur ' c='ser arthur dayne' assert(isequal(longest_sub_common_3d(a,b,c),7))

a = ' arthur' b = 'ser arthur ' c = 'ser arthur dayne'

4   Pass
a=[105 29 60 106 30 28 103 8 34 66 23 71 89 56 73 89 26 67 13 58 94 103 56 31 73 102 57 109 22 13 34 45 47 35 78 11 45 33 35 12 66 32 18 1 32 62 97 5 101 15 93 89 102 16 57 45 20 64 68 24 58 110 55 78 46 4 33 89 39 10 57 41 83 59 90 91 22 14 92 71 2 100 58 61 68 85 95 43 10 82 37 94 42 92 20 15 98 5 77 82 49 43 109 45 49 18 37 35 100 28 35] b=[46 79 16 97 10 52 4 84 78 24 76 62 95 63 101 47 40 55 29 104 52 29 48 78 45 21 96 65 42 25 25 58 49 83 8 95 76 16 96 23 68 61 19 1 86 85 47 7 66 20 81 60 29 102 85 99 8 21 82 78 87 56 48 68 95 75 59 34 79 43 64 99 94 100 105 91 1 1 10 29 3 48 38 61 103 34 38 96 38 16 57 96 43 78 70 50 53 106 10 32 50 66 98 53 49 83 52 96 52 56 55] %c=[46 79 16 97 10 52 4 84 78 24 76 62 95 63 101 47 40 55 29 104 52 29 48 78 45 21 96 65 42 25 25 58 49 83 8 95 76 16 96 23 68 61 19 1 86 85 47 7 66 20 81 60 29 102 85 99 8 21 82 78 87 56 48 68 95 75 59 34 79 43 64 99 94 100 105 91 1 1 10 29 3 48 38 61 103 34 38 96 38 16 57 96 43 78 70 50 53 106 10 32 50 66 98 53 49 83 52 96 52 56 55] c=[26 10 8 99 26 96 80 97 105 16 44 109 72 100 54 2 70 26 59 81 68 66 49 28 48 2 68 107 11 4 99 28 1 91 16 98 11 40 66 65 75 72 49 16 84 27 73 96 10 108 4 93 93 6 61 105 36 90 67 88 89 6 32 73 55 108 84 64 34 29 99 50 91 11 96 4 100 100 59 14 20 79 93 4 85 107 39 71 39 25 88 81 31 65 47 11 3 55 31 38 32 19 45 78 23 74 50 49 20 22 69] assert(isequal(longest_sub_common_3d(a,b,c),6))

a = Columns 1 through 29 105 29 60 106 30 28 103 8 34 66 23 71 89 56 73 89 26 67 13 58 94 103 56 31 73 102 57 109 22 Columns 30 through 58 13 34 45 47 35 78 11 45 33 35 12 66 32 18 1 32 62 97 5 101 15 93 89 102 16 57 45 20 64 Columns 59 through 87 68 24 58 110 55 78 46 4 33 89 39 10 57 41 83 59 90 91 22 14 92 71 2 100 58 61 68 85 95 Columns 88 through 111 43 10 82 37 94 42 92 20 15 98 5 77 82 49 43 109 45 49 18 37 35 100 28 35 b = Columns 1 through 29 46 79 16 97 10 52 4 84 78 24 76 62 95 63 101 47 40 55 29 104 52 29 48 78 45 21 96 65 42 Columns 30 through 58 25 25 58 49 83 8 95 76 16 96 23 68 61 19 1 86 85 47 7 66 20 81 60 29 102 85 99 8 21 Columns 59 through 87 82 78 87 56 48 68 95 75 59 34 79 43 64 99 94 100 105 91 1 1 10 29 3 48 38 61 103 34 38 Columns 88 through 111 96 38 16 57 96 43 78 70 50 53 106 10 32 50 66 98 53 49 83 52 96 52 56 55 c = Columns 1 through 29 26 10 8 99 26 96 80 97 105 16 44 109 72 100 54 2 70 26 59 81 68 66 49 28 48 2 68 107 11 Columns 30 through 58 4 99 28 1 91 16 98 11 40 66 65 75 72 49 16 84 27 73 96 10 108 4 93 93 6 61 105 36 90 Columns 59 through 87 67 88 89 6 32 73 55 108 84 64 34 29 99 50 91 11 96 4 100 100 59 14 20 79 93 4 85 107 39 Columns 88 through 111 71 39 25 88 81 31 65 47 11 3 55 31 38 32 19 45 78 23 74 50 49 20 22 69

5   Pass
a=repelem('abc',1,50) b=repelem('acb',1,50) c=repelem('acdb',1,50) assert(isequal(longest_sub_common_3d(a,b,c),100))

a = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccc' b = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccccccccccccccccbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' c = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'

Suggested Problems

More from this Author149

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!