Cody

# Problem 68. Kaprekar Steps

Solution 209705

Submitted on 27 Feb 2013 by bartekltg
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))

v = 2367 w = 5265 v = 2556 w = 3996 v = 3699 w = 6264 v = 2466 w = 4176 v = 1467 w = 6174

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

v = 0003 w = 2997 v = 2799 w = 7173 v = 1377 w = 6354 v = 3456 w = 3087 v = 0378 w = 8352 v = 2358 w = 6174

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

v = 0169 w = 9441 v = 1449 w = 7992 v = 2799 w = 7173 v = 1377 w = 6354 v = 3456 w = 3087 v = 0378 w = 8352 v = 2358 w = 6174

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

v = 3333 w = 0

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

v = 0001 w = 999 v = 0999 w = 8991 v = 1899 w = 8082 v = 0288 w = 8532 v = 2358 w = 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))

v = 1234 w = 3087 v = 0378 w = 8352 v = 2358 w = 6174

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

v = 1134 w = 3177 v = 1377 w = 6354 v = 3456 w = 3087 v = 0378 w = 8352 v = 2358 w = 6174

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

v = 0088 w = 8712 v = 1278 w = 7443 v = 3447 w = 3996 v = 3699 w = 6264 v = 2466 w = 4176 v = 1467 w = 6174