Cody

Problem 45231. Generate Golomb's sequence

Solution 2114777

Submitted on 2 Feb 2020
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   Fail
n = 18; y_correct = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18]; assert(isequal(euler_341_4(n),y_correct))

Index exceeds the number of array elements (1). Error in euler_341_4 (line 4) a(n+1) = 1 + a(n+1-a(a(n))) Error in Test1 (line 3) assert(isequal(euler_341_4(n),y_correct))

2   Fail
n = 5; y_correct = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5]; assert(isequal(euler_341_4(n),y_correct))

Index exceeds the number of array elements (1). Error in euler_341_4 (line 4) a(n+1) = 1 + a(n+1-a(a(n))) Error in Test2 (line 3) assert(isequal(euler_341_4(n),y_correct))

3   Fail
n = 12; y_correct = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12]; assert(isequal(euler_341_4(n),y_correct))

Index exceeds the number of array elements (1). Error in euler_341_4 (line 4) a(n+1) = 1 + a(n+1-a(a(n))) Error in Test3 (line 3) assert(isequal(euler_341_4(n),y_correct))

Suggested Problems

More from this Author148