Cody

# Problem 107. Count from 0 to N^M in base N.

Solution 15455

Submitted on 30 Jan 2012 by Pakize
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
%% M = 2; N = 2; y_correct = [0 0 1 1; 0 1 0 1]; assert(isequal(countInBaseN(M,N),y_correct))

x = 0 x = 0 1 x = 0 1 0 x = 0 1 0 1 x = 0 0 x = 0 0 1 1

2   Pass
%% M = 2; N = 3; y_correct = [ 0 0 0 1 1 1 2 2 2; 0 1 2 0 1 2 0 1 2]; assert(isequal(countInBaseN(M,N),y_correct))

x = 0 x = 0 1 x = 0 1 2 x = 0 1 2 0 x = 0 1 2 0 1 x = 0 1 2 0 1 2 x = 0 1 2 0 1 2 0 x = 0 1 2 0 1 2 0 1 x = 0 1 2 0 1 2 0 1 2 x = 0 0 0 x = 0 0 0 1 1 1 x = 0 0 0 1 1 1 2 2 2

3   Pass
%% M = 3; N = 4; y_correct = [ 0 0 0 0 0 1 0 0 2 0 0 3 0 1 0 0 1 1 0 1 2 0 1 3 0 2 0 0 2 1 0 2 2 0 2 3 0 3 0 0 3 1 0 3 2 0 3 3 1 0 0 1 0 1 1 0 2 1 0 3 1 1 0 1 1 1 1 1 2 1 1 3 1 2 0 1 2 1 1 2 2 1 2 3 1 3 0 1 3 1 1 3 2 1 3 3 2 0 0 2 0 1 2 0 2 2 0 3 2 1 0 2 1 1 2 1 2 2 1 3 2 2 0 2 2 1 2 2 2 2 2 3 2 3 0 2 3 1 2 3 2 2 3 3 3 0 0 3 0 1 3 0 2 3 0 3 3 1 0 3 1 1 3 1 2 3 1 3 3 2 0 3 2 1 3 2 2 3 2 3 3 3 0 3 3 1 3 3 2 3 3 3]; assert(isequal(countInBaseN(M,N),y_correct'))

x = 0 x = 0 1 x = 0 1 2 x = 0 1 2 3 x = 0 1 2 3 0 x = 0 1 2 3 0 1 x = 0 1 2 3 0 1 2 x = 0 1 2 3 0 1 2 3 x = 0 1 2 3 0 1 2 3 0 x = 0 1 2 3 0 1 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Column 11 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 12 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 13 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 14 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 15 2 3 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 16 2 3 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 17 2 3 0 1 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 18 2 3 0 1 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 19 2 3 0 1 2 3 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Column 21 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 22 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 23 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 24 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 25 0 1 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 26 0 1 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 27 0 1 2 3 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 28 0 1 2 3 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 29 0 1 2 3 0 1 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Column 31 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 32 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 33 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 34 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 35 2 3 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 36 2 3 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 37 2 3 0 1 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 38 2 3 0 1 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 39 2 3 0 1 2 3 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Column 41 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Columns 41 through 42 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Columns 41 through 43 0 1 2 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Columns 41 through 44 0 1 2 3 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Columns 41 through 45 0 1 2 3 0 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Columns 41 through 46 0 1 2 3 0 1 x = Columns 1 through 10 0 1 2 3 0 1 2 3 0 1 Columns 11 through 20 2 3 0 1 2 3 0 1 2 3 Columns 21 through 30 0 1 2 3 0 1 2 3 0 1 Columns 31 through 40 2 3 0 1 2 3 0 1 2 3 Columns 41 through 47 0 1 2 3 0 1...