Cody

Problem 2674. Generalised Hamming Number

Solution 1929089

Submitted on 10 Sep 2019 by Gergely Patay
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
X = 5; n=5; y_correct = 5; assert(isequal(hamming2(X,n),y_correct))

maxp = 2 1 1 ans = 5

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

maxp = 3 2 1 ans = 9

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

maxp = 6 4 2 ans = 34

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

maxp = 6 4 2 2 ans = 46

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

maxp = 6 4 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 100

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

maxp = 6 4 2 2 1 1 ans = 62

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

maxp = 43 27 18 15 ans = 19674

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

maxp = 16 10 7 5 4 4 ans = 1848

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

maxp = 16 10 7 ans = 313

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

maxp = 16 10 7 ans = 327

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

maxp = 43 27 ans = 624

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

maxp = 16 ans = 17