Cody

# Problem 68. Kaprekar Steps

Solution 1070868

Submitted on 3 Dec 2016 by ABDELRAHMAN
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))

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

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

pp = 1 g = 3 0 0 0 y = 2997 pp = 2 y = 7173 pp = 3 y = 6354 pp = 4 y = 3087 pp = 5 y = 8352 pp = 6 y = 6174

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

pp = 1 g = 6 9 1 0 y = 9441 pp = 2 y = 7992 pp = 3 y = 7173 pp = 4 y = 6354 pp = 5 y = 3087 pp = 6 y = 8352 pp = 7 y = 6174

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

pp = Inf

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

pp = 1 g = 1 0 0 0 y = 999 pp = 2 g = 9 9 9 0 y = 8991 pp = 3 y = 8082 pp = 4 y = 8532 pp = 5 y = 6174

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

pp = 0

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

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

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

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

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

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

### Community Treasure Hunt

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

Start Hunting!
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}