Cody

# Problem 68. Kaprekar Steps

Solution 342165

Submitted on 30 Oct 2013 by John
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))

ans = 2367 x = 5265 ans = 2556 x = 3996 ans = 3699 x = 6264 ans = 2466 x = 4176 ans = 1467 x = 6174

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

ans = 0003 x = 2997 ans = 2799 x = 7173 ans = 1377 x = 6354 ans = 3456 x = 3087 ans = 0378 x = 8352 ans = 2358 x = 6174

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

ans = 0169 x = 9441 ans = 1449 x = 7992 ans = 2799 x = 7173 ans = 1377 x = 6354 ans = 3456 x = 3087 ans = 0378 x = 8352 ans = 2358 x = 6174

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

ans = 3333 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0 ans = 0000 x = 0

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

ans = 0001 x = 999 ans = 0999 x = 8991 ans = 1899 x = 8082 ans = 0288 x = 8532 ans = 2358 x = 6174

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

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

ans = 1234 x = 3087 ans = 0378 x = 8352 ans = 2358 x = 6174

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

ans = 1134 x = 3177 ans = 1377 x = 6354 ans = 3456 x = 3087 ans = 0378 x = 8352 ans = 2358 x = 6174

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

ans = 0088 x = 8712 ans = 1278 x = 7443 ans = 3447 x = 3996 ans = 3699 x = 6264 ans = 2466 x = 4176 ans = 1467 x = 6174