Cody

Problem 2674. Generalised Hamming Number

Solution 704101

Submitted on 21 Jul 2015 by Tomasz
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))

c = 3 c = 1 c = 1 c = 0 c = 5

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

c = 4 c = 3 c = 1 c = 1 c = 0 c = 9

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

c = 10 c = 8 c = 6 c = 4 c = 3 c = 2 c = 1 c = 0 c = 34

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

c = 6 c = 4 c = 3 c = 1 c = 1 c = 0 c = 15 c = 6 c = 3 c = 2 c = 1 c = 0 c = 12 c = 4 c = 3 c = 1 c = 0 c = 8 c = 3 c = 1 c = 1 c = 0 c = 5 c = 2 c = 1 c = 0 c = 3 c = 1 c = 1 c = 0 c = 2 c = 1 c = 0 c = 1 c = 0 c = 0 c = 46

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

c = 3 c = 1 c = 0 c = 4 c = 1 c = 0 c = 1 c = 0 c = 0 c = 5 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 6 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 7 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 8 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 9 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 10 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 11 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 12 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 13 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 14 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 15 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 16 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 17 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 18 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 ...

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

c = 3 c = 3 c = 1 c = 0 c = 7 c = 3 c = 1 c = 0 c = 4 c = 1 c = 0 c = 1 c = 0 c = 0 c = 12 c = 3 c = 1 c = 0 c = 4 c = 1 c = 0 c = 1 c = 1 c = 0 c = 1 c = 0 c = 0 c = 6 c = 2 c = 1 c = 0 c = 3 c = 1 c = 0 c = 1 c = 0 c = 0 c = 4 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 24 c = 3 c = 1 c = 1 c = 0 c = 5 c = 1 c = 1 c = 0 c = 2 c = 1 c = 0 c = 1 c = 0 c = 0 c = 8 c = 3 c = 1 c = 0 c = 4 c = 1 c = 0 c = 1 c = 0 c = 0 c = 5 c = 1 c = 0 c = 1 c = 1 c = 0 c = 1 c = 0 c = 0 c = 2 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 16 c = 3 c = 1 c = 0 c = 4 c = 1 c = 0 c = 1 c = 1 c = 1 c = 6 c = 1 c = 1 c = 0 c = 2 c = 1 c = 0 c = 1 c = 0 c = 0 c = 3 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 10 c = 2 c = 1 c = 0 c = 3 c = 1 c = 0 c = 1 c = 0 c = 0 c = 4 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 6 c = 1 c = 0 c = 1 c = 1 c = 0 c = 1 c = 0 c = 0 c = 2 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 3 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 2 c = 1 c = 0 c = 1 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 1 c = 0 c = 0 c = 0 c = 0 c = 62

7   Fail

Suggested Problems

More from this Author43

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!