Cody

# Problem 42283. Look and say Conway's sequence

Solution 2185436

Submitted on 31 Mar 2020 by Asif Newaz
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
seed = 1; n=5; y_correct = {'1';'11';'21';'1211';'111221'}; assert(isequal(lasnumber(seed,n),y_correct))

aa = 1 0 q = '11' aa = 1 1 0 q = '21' aa = 2 1 0 q = '12' q = '1211' aa = 1 2 1 1 0 q = '11' q = '1112' q = '111221'

2   Pass
seed = 4; n=10; y_correct = {'4';'14';'1114';'3114';'132114';'1113122114';'311311222114';'13211321322114';'1113122113121113222114';'31131122211311123113322114'}; assert(isequal(lasnumber(seed,n),y_correct))

aa = 4 0 q = '14' aa = 1 4 0 q = '11' q = '1114' aa = 1 1 1 4 0 q = '31' q = '3114' aa = 3 1 1 4 0 q = '13' q = '1321' q = '132114' aa = 1 3 2 1 1 4 0 q = '11' q = '1113' q = '111312' q = '11131221' q = '1113122114' aa = 1 1 1 3 1 2 2 1 1 4 0 q = '31' q = '3113' q = '311311' q = '31131122' q = '3113112221' q = '311311222114' aa = 3 1 1 3 1 1 2 2 2 1 1 4 0 q = '13' q = '1321' q = '132113' q = '13211321' q = '1321132132' q = '132113213221' q = '13211321322114' aa = 1 3 2 1 1 3 2 1 3 2 2 1 1 4 0 q = '11' q = '1113' q = '111312' q = '11131221' q = '1113122113' q = '111312211312' q = '11131221131211' q = '1113122113121113' q = '111312211312111322' q = '11131221131211132221' q = '1113122113121113222114' aa = 1 1 1 3 1 2 2 1 1 3 1 2 1 1 1 3 2 2 2 1 1 4 0 q = '31' q = '3113' q = '311311' q = '31131122' q = '3113112221' q = '311311222113' q = '31131122211311' q = '3113112221131112' q = '311311222113111231' q = '31131122211311123113' q = '3113112221131112311332' q = '311311222113111231133221' q = '31131122211311123113322114'

3   Pass
seed = 22; n=5; y_correct = {'22';'22';'22';'22';'22'} assert(isequal(lasnumber(seed,n),y_correct))

y_correct = 5×1 cell array {'22'} {'22'} {'22'} {'22'} {'22'} aa = 2 2 0 q = '22' aa = 2 2 0 q = '22' aa = 2 2 0 q = '22' aa = 2 2 0 q = '22'

### Community Treasure Hunt

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

Start Hunting!