Cody

# Problem 2674. Generalised Hamming Number

Solution 1866130

Submitted on 5 Jul 2019
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
X = 5; n=5; y_correct = 5; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 s3 = 0 1 s5 = 0 1 s7 = 0

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test1 (line 4) assert(isequal(hamming2(X,n),y_correct))

2   Fail
X = 10; n=5; y_correct = 9; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 s3 = 0 1 2 s5 = 0 1 s7 = 0 1

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test2 (line 4) assert(isequal(hamming2(X,n),y_correct))

3   Fail
X = 100; n=5; y_correct = 34; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 s3 = 0 1 2 3 4 s5 = 0 1 2 s7 = 0 1 2

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test3 (line 4) assert(isequal(hamming2(X,n),y_correct))

4   Fail
X = 100; n=7; y_correct = 46; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 s3 = 0 1 2 3 4 s5 = 0 1 2 s7 = 0 1 2

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test4 (line 4) assert(isequal(hamming2(X,n),y_correct))

5   Fail
X = 100; n=100; y_correct = 100; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 s3 = 0 1 2 3 4 s5 = 0 1 2 s7 = 0 1 2

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test5 (line 4) assert(isequal(hamming2(X,n),y_correct))

6   Fail
X = 100; n=13; y_correct = 62; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 s3 = 0 1 2 3 4 s5 = 0 1 2 s7 = 0 1 2

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test6 (line 4) assert(isequal(hamming2(X,n),y_correct))

7   Fail
X = 10^13; n=7; y_correct = 19674; assert(isequal(hamming2(X,n),y_correct))

s2 = Columns 1 through 30 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 31 through 44 30 31 32 33 34 35 36 37 38 39 40 41 42 43 s3 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 s5 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 s7 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test7 (line 4) assert(isequal(hamming2(X,n),y_correct))

8   Fail
X = 10^5; n=13; y_correct = 1848; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 s3 = 0 1 2 3 4 5 6 7 8 9 10 s5 = 0 1 2 3 4 5 6 7 s7 = 0 1 2 3 4 5

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test8 (line 4) assert(isequal(hamming2(X,n),y_correct))

9   Fail
X = 10^5; n=5; y_correct = 313; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 s3 = 0 1 2 3 4 5 6 7 8 9 10 s5 = 0 1 2 3 4 5 6 7 s7 = 0 1 2 3 4 5

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test9 (line 4) assert(isequal(hamming2(X,n),y_correct))

10   Fail
X = 123456; n=5; y_correct = 327; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 s3 = 0 1 2 3 4 5 6 7 8 9 10 s5 = 0 1 2 3 4 5 6 7 s7 = 0 1 2 3 4 5 6

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test10 (line 4) assert(isequal(hamming2(X,n),y_correct))

11   Fail
X = 10^13; n=3; y_correct = 624; assert(isequal(hamming2(X,n),y_correct))

s2 = Columns 1 through 30 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 31 through 44 30 31 32 33 34 35 36 37 38 39 40 41 42 43 s3 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 s5 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 s7 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test11 (line 4) assert(isequal(hamming2(X,n),y_correct))

12   Fail
X = 123456; n=2; y_correct = 17; assert(isequal(hamming2(X,n),y_correct))

s2 = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 s3 = 0 1 2 3 4 5 6 7 8 9 10 s5 = 0 1 2 3 4 5 6 7 s7 = 0 1 2 3 4 5 6

Error using ngrid Too many output arguments. Error in hamming2 (line 7) [I,J,K]=ngrid(s2,s3,s5,s7) Error in Test12 (line 4) assert(isequal(hamming2(X,n),y_correct))