Cody

# Problem 68. Kaprekar Steps

Solution 1824302

Submitted on 23 May 2019 by silin yang
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))

j = 3276 b = 3 2 7 6 b = 3 2 7 6 c = 2 3 6 7 d = 7 6 3 2 min = 0 max = 0 min = 2000 max = 7000 min = 2300 max = 7600 min = 2360 max = 7630 min = 2367 max = 7632 j = 3276 5265 m = 2 b = 5 2 6 5 b = 5 2 6 5 c = 2 5 5 6 d = 6 5 5 2 min = 0 max = 0 min = 2000 max = 6000 min = 2500 max = 6500 min = 2550 max = 6550 min = 2556 max = 6552 j = 3276 5265 3996 m = 3 b = 3 9 9 6 b = 3 9 9 6 c = 3 6 9 9 d = 9 9 6 3 min = 0 max = 0 min = 3000 max = 9000 min = 3600 max = 9900 min = 3690 max = 9960 min = 3699 max = 9963 j = 3276 5265 3996 6264 m = 4 b = 6 2 6 4 b = 6 2 6 4 c = 2 4 6 6 d = 6 6 4 2 min = 0 max = 0 min = 2000 max = 6000 min = 2400 max = 6600 min = 2460 max = 6640 min = 2466 max = 6642 j = 3276 5265 3996 6264 4176 m = 5 b = 4 1 7 6 b = 4 1 7 6 c = 1 4 6 7 d = 7 6 4 1 min = 0 max = 0 min = 1000 max = 7000 min = 1400 max = 7600 min = 1460 max = 7640 min = 1467 max = 7641 j = 3276 5265 3996 6264 4176 6174 m = 6 y = 5

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

j = 3 b = 3 j = 3000 b = 3 0 0 0 c = 0 0 0 3 d = 3 0 0 0 min = 0 max = 0 min = 0 max = 3000 min = 0 max = 3000 min = 0 max = 3000 min = 3 max = 3000 j = 3000 2997 m = 2 b = 2 9 9 7 b = 2 9 9 7 c = 2 7 9 9 d = 9 9 7 2 min = 0 max = 0 min = 2000 max = 9000 min = 2700 max = 9900 min = 2790 max = 9970 min = 2799 max = 9972 j = 3000 2997 7173 m = 3 b = 7 1 7 3 b = 7 1 7 3 c = 1 3 7 7 d = 7 7 3 1 min = 0 max = 0 min = 1000 max = 7000 min = 1300 max = 7700 min = 1370 max = 7730 min = 1377 max = 7731 j = 3000 2997 7173 6354 m = 4 b = 6 3 5 4 b = 6 3 5 4 c = 3 4 5 6 d = 6 5 4 3 min = 0 max = 0 min = 3000 max = 6000 min = 3400 max = 6500 min = 3450 max = 6540 min = 3456 max = 6543 j = 3000 2997 7173 6354 3087 m = 5 b = 3 0 8 7 b = 3 0 8 7 c = 0 3 7 8 d = 8 7 3 0 min = 0 max = 0 min = 0 max = 8000 min = 300 max = 8700 min = 370 max = 8730 min = 378 max = 8730 j = 3000 2997 7173 6354 3087 8352 m = 6 b = 8 3 5 2 b = 8 3 5 2 c = 2 3 5 8 d = 8 5 3 2 min = 0 max = 0 min = 2000 max = 8000 min = 2300 max = 8500 min = 2350 max = 8530 min = 2358 max = 8532 j = 3000 2997 7173 6354 3087 8352 6174 m = 7 y = 6

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

j = 691 b = 6 9 1 j = 6910 b = 6 9 1 0 c = 0 1 6 9 d = 9 6 1 0 min = 0 max = 0 min = 0 max = 9000 min = 100 max = 9600 min = 160 max = 9610 min = 169 max = 9610 j = 6910 9441 m = 2 b = 9 4 4 1 b = 9 4 4 1 c = 1 4 4 9 d = 9 4 4 1 min = 0 max = 0 min = 1000 max = 9000 min = 1400 max = 9400 min = 1440 max = 9440 min = 1449 max = 9441 j = 6910 9441 7992 m = 3 b = 7 9 9 2 b = 7 9 9 2 c = 2 7 9 9 d = 9 9 7 2 min = 0 max = 0 min = 2000 max = 9000 min = 2700 max = 9900 min = 2790 max = 9970 min = 2799 max = 9972 j = 6910 9441 7992 7173 m = 4 b = 7 1 7 3 b = 7 1 7 3 c = 1 3 7 7 d = 7 7 3 1 min = 0 max = 0 min = 1000 max = 7000 min = 1300 max = 7700 min = 1370 max = 7730 min = 1377 max = 7731 j = 6910 9441 7992 7173 6354 m = 5 b = 6 3 5 4 b = 6 3 5 4 c = 3 4 5 6 d = 6 5 4 3 min = 0 max = 0 min = 3000 max = 6000 min = 3400 max = 6500 min = 3450 max = 6540 min = 3456 max = 6543 j = 6910 9441 7992 7173 6354 3087 m = 6 b = 3 0 8 7 b = 3 0 8 7 c = 0 3 7 8 d = 8 7 3 0 min = 0 max = 0 min = 0 max = 8000 min = 300 max = 8700 min = 370 max = 8730 min = 378 max = 8730 j = 6910 9441 7992 7173 6354 3087 8352 m = 7 b = 8 3 5 2 b = 8 3 5 2 c = 2 3 5 8 d = 8 5 3 2 min = 0 max = 0 min = 2000 max = 8000 min = 2300 max = 8500 min = 2350 max = 8530 min = 2358 max = 8532 j = 6910 9441 7992 7173 6354 3087 8352 6174 m = 8 y = 7

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

j = 3333 b = 3 3 3 3 b = 3 3 3 3 c = 3 3 3 3 d = 3 3 3 3 min = 0 max = 0 min = 3000 max = 3000 min = 3300 max = 3300 min = 3330 max = 3330 min = 3333 max = 3333 j = 3333 0 m = 2 y = Inf

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

j = 1 b = 1 j = 1000 b = 1 0 0 0 c = 0 0 0 1 d = 1 0 0 0 min = 0 max = 0 min = 0 max = 1000 min = 0 max = 1000 min = 0 max = 1000 min = 1 max = 1000 j = 1000 999 m = 2 b = 9 9 9 j = 1000 9990 b = 9 9 9 0 c = 0 9 9 9 d = 9 9 9 0 min = 0 max = 0 min = 0 max = 9000 min = 900 max = 9900 min = 990 max = 9990 min = 999 max = 9990 j = 1000 9990 8991 m = 3 b = 8 9 9 1 b = 8 9 9 1 c = 1 8 9 9 d = 9 9 8 1 min = 0 max = 0 min = 1000 max = 9000 min = 1800 max = 9900 min = 1890 max = 9980 min = 1899 max = 9981 j = 1000 9990 8991 8082 m = 4 b = 8 0 8 2 b = 8 0 8 2 c = 0 2 8 8 d = 8 8 2 0 min = 0 max = 0 min = 0 max = 8000 min = 200 max = 8800 min = 280 max = 8820 min = 288 max = 8820 j = 1000 9990 8991 8082 8532 m = 5 b = 8 5 3 2 b = 8 5 3 2 c = 2 3 5 8 d = 8 5 3 2 min = 0 max = 0 min = 2000 max = 8000 min = 2300 max = 8500 min = 2350 max = 8530 min = 2358 max = 8532 j = 1000 9990 8991 8082 8532 6174 m = 6 y = 5

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

j = 6174 y = 0

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

j = 1234 b = 1 2 3 4 b = 1 2 3 4 c = 1 2 3 4 d = 4 3 2 1 min = 0 max = 0 min = 1000 max = 4000 min = 1200 max = 4300 min = 1230 max = 4320 min = 1234 max = 4321 j = 1234 3087 m = 2 b = 3 0 8 7 b = 3 0 8 7 c = 0 3 7 8 d = 8 7 3 0 min = 0 max = 0 min = 0 max = 8000 min = 300 max = 8700 min = 370 max = 8730 min = 378 max = 8730 j = 1234 3087 8352 m = 3 b = 8 3 5 2 b = 8 3 5 2 c = 2 3 5 8 d = 8 5 3 2 min = 0 max = 0 min = 2000 max = 8000 min = 2300 max = 8500 min = 2350 max = 8530 min = 2358 max = 8532 j = 1234 3087 8352 6174 m = 4 y = 3

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

j = 3141 b = 3 1 4 1 b = 3 1 4 1 c = 1 1 3 4 d = 4 3 1 1 min = 0 max = 0 min = 1000 max = 4000 min = 1100 max = 4300 min = 1130 max = 4310 min = 1134 max = 4311 j = 3141 3177 m = 2 b = 3 1 7 7 b = 3 1 7 7 c = 1 3 7 7 d = 7 7 3 1 min = 0 max = 0 min = 1000 max = 7000 min = 1300 max = 7700 min = 1370 max = 7730 min = 1377 max = 7731 j = 3141 3177 6354 m = 3 b = 6 3 5 4 b = 6 3 5 4 c = 3 4 5 6 d = 6 5 4 3 min = 0 max = 0 min = 3000 max = 6000 min = 3400 max = 6500 min = 3450 max = 6540 min = 3456 max = 6543 j = 3141 3177 6354 3087 m = 4 b = 3 0 8 7 b = 3 0 8 7 c = 0 3 7 8 d = 8 7 3 0 min = 0 max = 0 min = 0 max = 8000 min = 300 max = 8700 min = 370 max = 8730 min = 378 max = 8730 j = 3141 3177 6354 3087 8352 m = 5 b = 8 3 5 2 b = 8 3 5 2 c = 2 3 5 8 d = 8 5 3 2 min = 0 max = 0 min = 2000 max = 8000 min = 2300 max = 8500 min = 2350 max = 8530 min = 2358 max = 8532 j = 3141 3177 6354 3087 8352 6174 m = 6 y = 5

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

j = 8080 b = 8 0 8 0 b = 8 0 8 0 c = 0 0 8 8 d = 8 8 0 0 min = 0 max = 0 min = 0 max = 8000 min = 0 max = 8800 min = 80 max = 8800 min = 88 max = 8800 j = 8080 8712 m = 2 b = 8 7 1 2 b = 8 7 1 2 c = 1 2 7 8 d = 8 7 2 1 min = 0 max = 0 min = 1000 max = 8000 min = 1200 max = 8700 min = 1270 max = 8720 min = 1278 max = 8721 j = 8080 8712 7443 m = 3 b = 7 4 4 3 b = 7 4 4 3 c = 3 4 4 7 d = 7 4 4 3 min = 0 max = 0 min = 3000 max = 7000 min = 3400 max = 7400 min = 3440 max = 7440 min = 3447 max = 7443 j = 8080 8712 7443 3996 m = 4 b = 3 9 9 6 b = 3 9 9 6 c = 3 6 9 9 d = 9 9 6 3 min = 0 max = 0 min = 3000 max = 9000 min = 3600 max = 9900 min = 3690 max = 9960 min = 3699 max = 9963 j = 8080 8712 7443 3996 6264 m = 5 b = 6 2 6 4 b = 6 2 6 4 c = 2 4 6 6 d = 6 6 4 2 min = 0 max = 0 min = 2000 max = 6000 min = 2400 max = 6600 min = 2460 max = 6640 min = 2466 max = 6642 j = 8080 8712 7443 3996 6264 4176 m = 6 b = 4 1 7 6 b = 4 1 7 6 c = 1 4 6 7 d = 7 6 4 1 min = 0 max = 0 min = 1000 max = 7000 min = 1400 max = 7600 min = 1460 max = 7640 min = 1467 max = 7641 j = 8080 8712 7443 3996 6264 4176 6174 m = 7 y = 6