Cody

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

Solution 1220754

Submitted on 26 Jun 2017 by Augusto Mazzei
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))

str = '00' str = '01' str = '10' str = '11'

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))

str = '00' str = '01' str = '02' str = '10' str = '11' str = '12' str = '20' str = '21' str = '22'

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'))

str = '000' str = '001' str = '002' str = '003' str = '010' str = '011' str = '012' str = '013' str = '020' str = '021' str = '022' str = '023' str = '030' str = '031' str = '032' str = '033' str = '100' str = '101' str = '102' str = '103' str = '110' str = '111' str = '112' str = '113' str = '120' str = '121' str = '122' str = '123' str = '130' str = '131' str = '132' str = '133' str = '200' str = '201' str = '202' str = '203' str = '210' str = '211' str = '212' str = '213' str = '220' str = '221' str = '222' str = '223' str = '230' str = '231' str = '232' str = '233' str = '300' str = '301' str = '302' str = '303' str = '310' str = '311' str = '312' str = '313' str = '320' str = '321' str = '322' str = '323' str = '330' str = '331' str = '332' str = '333'

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!