Cody

Problem 45321. Kolakoski Sequence

Solution 2277831

Submitted on 13 May 2020 by Stephen
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 = [2,1]; x=10; y_correct = [2 2 1 1 2 1 2 2 1 2 ]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

2   Pass
a = [2,1]; x=15; y_correct = [2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 ]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

3   Pass
a = [1,3,1,2]; x=30; y_correct = [1, 3, 3, 3, 1, 1, 1, 2, 2, 2, 1, 3, 1, 2, 2, 1, 1, 3, 3, 1, 2, 2, 2, 1, 3, 3, 1, 1, 2, 1]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

4   Pass
a = [4,2]; x=15; y_correct = [ 4 4 4 4 2 2 2 2 4 4 4 4 2 2 2]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

5   Pass
a = [1,3,2]; x=15; y_correct = [1 3 3 3 2 2 2 1 1 1 3 3 2 2 1]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

6   Pass
a = [1,3,2,1]; x=30; y_correct = [1, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 2, 2, 1, 1, 3, 2, 1, 1, 1, 1, 3, 3, 3, 2, 2, 1]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

7   Pass
a = [3,12,1,5]; x=40; y_correct = [3 3 3 12 12 12 1 1 1 5 5 5 5 5 5 5 5 5 5 5 5 3 3 3 3 3 3 3 3 3 3 3 3 12 12 12 12 12 12 12]; assert(isequal( kolakoski_seq_3(a,x),y_correct))

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!