Cody

Solution 113606

Submitted on 17 Jul 2012 by Ben
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))

s = 3276 s = 7632 s = 5265 y = 1 s = 6552 s = 3996 y = 2 s = 9963 s = 6264 y = 3 s = 6642 s = 4176 y = 4 s = 7641 s = 6174 y = 5

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

s = 0003 s = 3000 s = 2997 y = 1 s = 9972 s = 7173 y = 2 s = 7731 s = 6354 y = 3 s = 6543 s = 3087 y = 4 s = 8730 s = 8352 y = 5 s = 8532 s = 6174 y = 6

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

s = 0691 s = 9610 s = 9441 y = 1 s = 9441 s = 7992 y = 2 s = 9972 s = 7173 y = 3 s = 7731 s = 6354 y = 4 s = 6543 s = 3087 y = 5 s = 8730 s = 8352 y = 6 s = 8532 s = 6174 y = 7

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

s = 3333 y = Inf

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

s = 0001 s = 1000 s = 0999 y = 1 s = 9990 s = 8991 y = 2 s = 9981 s = 8082 y = 3 s = 8820 s = 8532 y = 4 s = 8532 s = 6174 y = 5

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

s = 6174

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

s = 1234 s = 4321 s = 3087 y = 1 s = 8730 s = 8352 y = 2 s = 8532 s = 6174 y = 3

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

s = 3141 s = 4311 s = 3177 y = 1 s = 7731 s = 6354 y = 2 s = 6543 s = 3087 y = 3 s = 8730 s = 8352 y = 4 s = 8532 s = 6174 y = 5

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

s = 8080 s = 8800 s = 8712 y = 1 s = 8721 s = 7443 y = 2 s = 7443 s = 3996 y = 3 s = 9963 s = 6264 y = 4 s = 6642 s = 4176 y = 5 s = 7641 s = 6174 y = 6