Cody

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

Solution 1464383

Submitted on 16 Mar 2018 by David Verrelli
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))

d = '0' f = '000000000' g = 0 0 0 0 0 0 0 0 0 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 d = '1' f = '000000001' g = 0 0 0 0 0 0 0 0 1 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 d = '10' f = '000000010' g = 0 0 0 0 0 0 0 1 0 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 d = '11' f = '000000011' g = 0 0 0 0 0 0 0 1 1 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 y = 0 0 1 1 0 1 0 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))

d = '0' f = '000000000' g = 0 0 0 0 0 0 0 0 0 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 d = '1' f = '000000001' g = 0 0 0 0 0 0 0 0 1 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 d = '2' f = '000000002' g = 0 0 0 0 0 0 0 0 2 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 d = '10' f = '000000010' g = 0 0 0 0 0 0 0 1 0 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 d = '11' f = '000000011' g = 0 0 0 0 0 0 0 1 1 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 d = '12' f = '000000012' g = 0 0 0 0 0 0 0 1 2 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 d = '20' f = '000000020' g = 0 0 0 0 0 0 0 2 0 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 2 0 d = '21' f = '000000021' g = 0 0 0 0 0 0 0 2 1 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 1 d = '22' f = '000000022' g = 0 0 0 0 0 0 0 2 2 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 2 2 y = 0 0 0 1 1 1 2 2 2 0 1 2 0 1 2 0 1 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'))

d = '0' f = '000000000' g = 0 0 0 0 0 0 0 0 0 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 d = '1' f = '000000001' g = 0 0 0 0 0 0 0 0 1 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 d = '2' f = '000000002' g = 0 0 0 0 0 0 0 0 2 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 d = '3' f = '000000003' g = 0 0 0 0 0 0 0 0 3 Name Size Bytes Class Attributes d 1x1 2 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 d = '10' f = '000000010' g = 0 0 0 0 0 0 0 1 0 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 d = '11' f = '000000011' g = 0 0 0 0 0 0 0 1 1 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 d = '12' f = '000000012' g = 0 0 0 0 0 0 0 1 2 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 d = '13' f = '000000013' g = 0 0 0 0 0 0 0 1 3 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 3 d = '20' f = '000000020' g = 0 0 0 0 0 0 0 2 0 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 2 0 d = '21' f = '000000021' g = 0 0 0 0 0 0 0 2 1 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 1 d = '22' f = '000000022' g = 0 0 0 0 0 0 0 2 2 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 2 2 d = '23' f = '000000023' g = 0 0 0 0 0 0 0 2 3 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 2 3 d = '30' f = '000000030' g = 0 0 0 0 0 0 0 3 0 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 2 3 0 0 0 0 0 0 0 3 0 d = '31' f = '000000031' g = 0 0 0 0 0 0 0 3 1 Name Size Bytes Class Attributes d 1x2 4 char f 1x9 18 char g 1x9 72 double y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 ...