Cody

Solution 1199043

Submitted on 27 May 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
x = 3276; y_correct = 5; assert(isequal(KaprekarSteps(x),y_correct))

e = '3276' e = '3276' s = 2 3 6 7 e = '5265' s = 2 5 5 6 e = '3996' s = 3 6 9 9 e = '6264' s = 2 4 6 6 e = '4176' s = 1 4 6 7 e = '6174'

2   Pass
x = 3; y_correct = 6; assert(isequal(KaprekarSteps(x),y_correct))

e = '3' e = ' 3' s = 0 0 0 3 e = '2997' s = 2 7 9 9 e = '7173' s = 1 3 7 7 e = '6354' s = 3 4 5 6 e = '3087' s = 0 3 7 8 e = '8352' s = 2 3 5 8 e = '6174'

3   Pass
x = 691; y_correct = 7; assert(isequal(KaprekarSteps(x),y_correct))

e = '691' e = ' 691' s = 0 1 6 9 e = '9441' s = 1 4 4 9 e = '7992' s = 2 7 9 9 e = '7173' s = 1 3 7 7 e = '6354' s = 3 4 5 6 e = '3087' s = 0 3 7 8 e = '8352' s = 2 3 5 8 e = '6174'

4   Pass
x = 3333; y_correct = Inf; assert(isequal(KaprekarSteps(x),y_correct))

e = '3333' e = '3333' y = Inf

5   Pass
x = 1; y_correct = 5; assert(isequal(KaprekarSteps(x),y_correct))

e = '1' e = ' 1' s = 0 0 0 1 e = ' 999' s = 0 9 9 9 e = '8991' s = 1 8 9 9 e = '8082' s = 0 2 8 8 e = '8532' s = 2 3 5 8 e = '6174'

6   Pass
x = 6174; y_correct = 0; assert(isequal(KaprekarSteps(x),y_correct))

e = '6174' e = '6174'

7   Pass
x = 1234; y_correct = 3; assert(isequal(KaprekarSteps(x),y_correct))

e = '1234' e = '1234' s = 1 2 3 4 e = '3087' s = 0 3 7 8 e = '8352' s = 2 3 5 8 e = '6174'

8   Pass
x = 3141; y_correct = 5; assert(isequal(KaprekarSteps(x),y_correct))

e = '3141' e = '3141' s = 1 1 3 4 e = '3177' s = 1 3 7 7 e = '6354' s = 3 4 5 6 e = '3087' s = 0 3 7 8 e = '8352' s = 2 3 5 8 e = '6174'

9   Pass
x = 8080; y_correct = 6; assert(isequal(KaprekarSteps(x),y_correct))

e = '8080' e = '8080' s = 0 0 8 8 e = '8712' s = 1 2 7 8 e = '7443' s = 3 4 4 7 e = '3996' s = 3 6 9 9 e = '6264' s = 2 4 6 6 e = '4176' s = 1 4 6 7 e = '6174'