Cody

# Problem 68. Kaprekar Steps

Solution 209709

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 = 7632 w = 5265 v = 6552 w = 3996 v = 9963 w = 6264 v = 6642 w = 4176 v = 7641 w = 6174

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

v = 3000 w = 2997 v = 9972 w = 7173 v = 7731 w = 6354 v = 6543 w = 3087 v = 8730 w = 8352 v = 8532 w = 6174

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

v = 9610 w = 9441 v = 9441 w = 7992 v = 9972 w = 7173 v = 7731 w = 6354 v = 6543 w = 3087 v = 8730 w = 8352 v = 8532 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 = 1000 w = 999 v = 9990 w = 8991 v = 9981 w = 8082 v = 8820 w = 8532 v = 8532 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 = 4321 w = 3087 v = 8730 w = 8352 v = 8532 w = 6174

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

v = 4311 w = 3177 v = 7731 w = 6354 v = 6543 w = 3087 v = 8730 w = 8352 v = 8532 w = 6174

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

v = 8800 w = 8712 v = 8721 w = 7443 v = 7443 w = 3996 v = 9963 w = 6264 v = 6642 w = 4176 v = 7641 w = 6174

### Community Treasure Hunt

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

Start Hunting!