Cody

Problem 45231. Generate Golomb's sequence

Solution 2114779

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))

a = 1 2 a = 1 2 2 a = 1 2 2 3 a = 1 2 2 3 3 a = 1 2 2 3 3 4 a = 1 2 2 3 3 4 4 a = 1 2 2 3 3 4 4 4 a = 1 2 2 3 3 4 4 4 5 a = 1 2 2 3 3 4 4 4 5 5 a = 1 2 2 3 3 4 4 4 5 5 5 a = 1 2 2 3 3 4 4 4 5 5 5 6 a = 1 2 2 3 3 4 4 4 5 5 5 6 6 a = 1 2 2 3 3 4 4 4 5 5 5 6 6 6 a = 1 2 2 3 3 4 4 4 5 5 5 6 6 6 6 a = 1 2 2 3 3 4 4 4 5 5 5 6 6 6 6 7 a = 1 2 2 3 3 4 4 4 5 5 5 6 6 6 6 7 7 y = 1 2 2 3 3 4 4 4 5 5 5 6 6 6 6 7 7

Assertion failed.

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))

a = 1 2 a = 1 2 2 a = 1 2 2 3 y = 1 2 2 3

Assertion failed.

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))

a = 1 2 a = 1 2 2 a = 1 2 2 3 a = 1 2 2 3 3 a = 1 2 2 3 3 4 a = 1 2 2 3 3 4 4 a = 1 2 2 3 3 4 4 4 a = 1 2 2 3 3 4 4 4 5 a = 1 2 2 3 3 4 4 4 5 5 a = 1 2 2 3 3 4 4 4 5 5 5 y = 1 2 2 3 3 4 4 4 5 5 5

Assertion failed.