Cody

# Problem 68. Kaprekar Steps

Solution 1753630

Submitted on 18 Mar 2019 by Zain Faruqi
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))

y = 5265 c = 1 y = 3996 c = 2 y = 6264 c = 3 y = 4176 c = 4 y = 6174 c = 5

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

y = 2997 c = 1 y = 7173 c = 2 y = 6354 c = 3 y = 3087 c = 4 y = 8352 c = 5 y = 6174 c = 6

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

y = 9441 c = 1 y = 7992 c = 2 y = 7173 c = 3 y = 6354 c = 4 y = 3087 c = 5 y = 8352 c = 6 y = 6174 c = 7

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

y = 0 c = Inf

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

y = 999 c = 1 y = 8991 c = 2 y = 8082 c = 3 y = 8532 c = 4 y = 6174 c = 5

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))

y = 3087 c = 1 y = 8352 c = 2 y = 6174 c = 3

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

y = 3177 c = 1 y = 6354 c = 2 y = 3087 c = 3 y = 8352 c = 4 y = 6174 c = 5

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

y = 8712 c = 1 y = 7443 c = 2 y = 3996 c = 3 y = 6264 c = 4 y = 4176 c = 5 y = 6174 c = 6

### Community Treasure Hunt

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

Start Hunting!