Cody

Solution 1799862

Submitted on 29 Apr 2019 by Devineni Aslesha
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))

dig = 0 0 0 0 rem = 6 dig = 6 0 0 0 n1 = 327 rem = 7 dig = 6 7 0 0 n1 = 32 rem = 2 dig = 6 7 2 0 n1 = 3 rem = 3 dig = 6 7 2 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 3 6 7 diga = 2367 dig = 7 6 3 2 digd = 7632 x2 = 5265 n1 = 5265 dig = 0 0 0 0 rem = 5 dig = 5 0 0 0 n1 = 526 rem = 6 dig = 5 6 0 0 n1 = 52 rem = 2 dig = 5 6 2 0 n1 = 5 rem = 5 dig = 5 6 2 5 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 5 5 6 diga = 2556 dig = 6 5 5 2 digd = 6552 x2 = 3996 n1 = 3996 dig = 0 0 0 0 rem = 6 dig = 6 0 0 0 n1 = 399 rem = 9 dig = 6 9 0 0 n1 = 39 rem = 9 dig = 6 9 9 0 n1 = 3 rem = 3 dig = 6 9 9 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 3 6 9 9 diga = 3699 dig = 9 9 6 3 digd = 9963 x2 = 6264 n1 = 6264 dig = 0 0 0 0 rem = 4 dig = 4 0 0 0 n1 = 626 rem = 6 dig = 4 6 0 0 n1 = 62 rem = 2 dig = 4 6 2 0 n1 = 6 rem = 6 dig = 4 6 2 6 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 4 6 6 diga = 2466 dig = 6 6 4 2 digd = 6642 x2 = 4176 n1 = 4176 dig = 0 0 0 0 rem = 6 dig = 6 0 0 0 n1 = 417 rem = 7 dig = 6 7 0 0 n1 = 41 rem = 1 dig = 6 7 1 0 n1 = 4 rem = 4 dig = 6 7 1 4 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 4 6 7 diga = 1467 dig = 7 6 4 1 digd = 7641 x2 = 6174

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

x = 3000 dig = 0 0 0 0 rem = 0 dig = 0 0 0 0 n1 = 300 rem = 0 dig = 0 0 0 0 n1 = 30 rem = 0 dig = 0 0 0 0 n1 = 3 rem = 3 dig = 0 0 0 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 0 0 3 diga = 3 dig = 3 0 0 0 digd = 3000 x2 = 2997 n1 = 2997 dig = 0 0 0 0 rem = 7 dig = 7 0 0 0 n1 = 299 rem = 9 dig = 7 9 0 0 n1 = 29 rem = 9 dig = 7 9 9 0 n1 = 2 rem = 2 dig = 7 9 9 2 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 7 9 9 diga = 2799 dig = 9 9 7 2 digd = 9972 x2 = 7173 n1 = 7173 dig = 0 0 0 0 rem = 3 dig = 3 0 0 0 n1 = 717 rem = 7 dig = 3 7 0 0 n1 = 71 rem = 1 dig = 3 7 1 0 n1 = 7 rem = 7 dig = 3 7 1 7 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 3 7 7 diga = 1377 dig = 7 7 3 1 digd = 7731 x2 = 6354 n1 = 6354 dig = 0 0 0 0 rem = 4 dig = 4 0 0 0 n1 = 635 rem = 5 dig = 4 5 0 0 n1 = 63 rem = 3 dig = 4 5 3 0 n1 = 6 rem = 6 dig = 4 5 3 6 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 3 4 5 6 diga = 3456 dig = 6 5 4 3 digd = 6543 x2 = 3087 n1 = 3087 dig = 0 0 0 0 rem = 7 dig = 7 0 0 0 n1 = 308 rem = 8 dig = 7 8 0 0 n1 = 30 rem = 0 dig = 7 8 0 0 n1 = 3 rem = 3 dig = 7 8 0 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 3 7 8 diga = 378 dig = 8 7 3 0 digd = 8730 x2 = 8352 n1 = 8352 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 835 rem = 5 dig = 2 5 0 0 n1 = 83 rem = 3 dig = 2 5 3 0 n1 = 8 rem = 8 dig = 2 5 3 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 3 5 8 diga = 2358 dig = 8 5 3 2 digd = 8532 x2 = 6174

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

x = 6910 dig = 0 0 0 0 rem = 0 dig = 0 0 0 0 n1 = 691 rem = 1 dig = 0 1 0 0 n1 = 69 rem = 9 dig = 0 1 9 0 n1 = 6 rem = 6 dig = 0 1 9 6 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 1 6 9 diga = 169 dig = 9 6 1 0 digd = 9610 x2 = 9441 n1 = 9441 dig = 0 0 0 0 rem = 1 dig = 1 0 0 0 n1 = 944 rem = 4 dig = 1 4 0 0 n1 = 94 rem = 4 dig = 1 4 4 0 n1 = 9 rem = 9 dig = 1 4 4 9 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 4 4 9 diga = 1449 dig = 9 4 4 1 digd = 9441 x2 = 7992 n1 = 7992 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 799 rem = 9 dig = 2 9 0 0 n1 = 79 rem = 9 dig = 2 9 9 0 n1 = 7 rem = 7 dig = 2 9 9 7 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 7 9 9 diga = 2799 dig = 9 9 7 2 digd = 9972 x2 = 7173 n1 = 7173 dig = 0 0 0 0 rem = 3 dig = 3 0 0 0 n1 = 717 rem = 7 dig = 3 7 0 0 n1 = 71 rem = 1 dig = 3 7 1 0 n1 = 7 rem = 7 dig = 3 7 1 7 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 3 7 7 diga = 1377 dig = 7 7 3 1 digd = 7731 x2 = 6354 n1 = 6354 dig = 0 0 0 0 rem = 4 dig = 4 0 0 0 n1 = 635 rem = 5 dig = 4 5 0 0 n1 = 63 rem = 3 dig = 4 5 3 0 n1 = 6 rem = 6 dig = 4 5 3 6 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 3 4 5 6 diga = 3456 dig = 6 5 4 3 digd = 6543 x2 = 3087 n1 = 3087 dig = 0 0 0 0 rem = 7 dig = 7 0 0 0 n1 = 308 rem = 8 dig = 7 8 0 0 n1 = 30 rem = 0 dig = 7 8 0 0 n1 = 3 rem = 3 dig = 7 8 0 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 3 7 8 diga = 378 dig = 8 7 3 0 digd = 8730 x2 = 8352 n1 = 8352 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 835 rem = 5 dig = 2 5 0 0 n1 = 83 rem = 3 dig = 2 5 3 0 n1 = 8 rem = 8 dig = 2 5 3 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 3 5 8 diga = 2358 dig = 8 5 3 2 digd = 8532 x2 = 6174

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

dig = 0 0 0 0 rem = 3 dig = 3 0 0 0 n1 = 333 rem = 3 dig = 3 3 0 0 n1 = 33 rem = 3 dig = 3 3 3 0 n1 = 3 rem = 3 dig = 3 3 3 3 n1 = 0

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

x = 1000 dig = 0 0 0 0 rem = 0 dig = 0 0 0 0 n1 = 100 rem = 0 dig = 0 0 0 0 n1 = 10 rem = 0 dig = 0 0 0 0 n1 = 1 rem = 1 dig = 0 0 0 1 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 0 0 1 diga = 1 dig = 1 0 0 0 digd = 1000 x2 = 999 n1 = 999 dig = 0 0 0 0 rem = 9 dig = 9 0 0 0 n1 = 99 rem = 9 dig = 9 9 0 0 n1 = 9 rem = 9 dig = 9 9 9 0 n1 = 0 rem = 0 dig = 9 9 9 0 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 9 9 9 diga = 999 dig = 9 9 9 0 digd = 9990 x2 = 8991 n1 = 8991 dig = 0 0 0 0 rem = 1 dig = 1 0 0 0 n1 = 899 rem = 9 dig = 1 9 0 0 n1 = 89 rem = 9 dig = 1 9 9 0 n1 = 8 rem = 8 dig = 1 9 9 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 8 9 9 diga = 1899 dig = 9 9 8 1 digd = 9981 x2 = 8082 n1 = 8082 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 808 rem = 8 dig = 2 8 0 0 n1 = 80 rem = 0 dig = 2 8 0 0 n1 = 8 rem = 8 dig = 2 8 0 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 2 8 8 diga = 288 dig = 8 8 2 0 digd = 8820 x2 = 8532 n1 = 8532 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 853 rem = 3 dig = 2 3 0 0 n1 = 85 rem = 5 dig = 2 3 5 0 n1 = 8 rem = 8 dig = 2 3 5 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 3 5 8 diga = 2358 dig = 8 5 3 2 digd = 8532 x2 = 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))

dig = 0 0 0 0 rem = 4 dig = 4 0 0 0 n1 = 123 rem = 3 dig = 4 3 0 0 n1 = 12 rem = 2 dig = 4 3 2 0 n1 = 1 rem = 1 dig = 4 3 2 1 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 2 3 4 diga = 1234 dig = 4 3 2 1 digd = 4321 x2 = 3087 n1 = 3087 dig = 0 0 0 0 rem = 7 dig = 7 0 0 0 n1 = 308 rem = 8 dig = 7 8 0 0 n1 = 30 rem = 0 dig = 7 8 0 0 n1 = 3 rem = 3 dig = 7 8 0 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 3 7 8 diga = 378 dig = 8 7 3 0 digd = 8730 x2 = 8352 n1 = 8352 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 835 rem = 5 dig = 2 5 0 0 n1 = 83 rem = 3 dig = 2 5 3 0 n1 = 8 rem = 8 dig = 2 5 3 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 3 5 8 diga = 2358 dig = 8 5 3 2 digd = 8532 x2 = 6174

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

dig = 0 0 0 0 rem = 1 dig = 1 0 0 0 n1 = 314 rem = 4 dig = 1 4 0 0 n1 = 31 rem = 1 dig = 1 4 1 0 n1 = 3 rem = 3 dig = 1 4 1 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 1 3 4 diga = 1134 dig = 4 3 1 1 digd = 4311 x2 = 3177 n1 = 3177 dig = 0 0 0 0 rem = 7 dig = 7 0 0 0 n1 = 317 rem = 7 dig = 7 7 0 0 n1 = 31 rem = 1 dig = 7 7 1 0 n1 = 3 rem = 3 dig = 7 7 1 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 3 7 7 diga = 1377 dig = 7 7 3 1 digd = 7731 x2 = 6354 n1 = 6354 dig = 0 0 0 0 rem = 4 dig = 4 0 0 0 n1 = 635 rem = 5 dig = 4 5 0 0 n1 = 63 rem = 3 dig = 4 5 3 0 n1 = 6 rem = 6 dig = 4 5 3 6 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 3 4 5 6 diga = 3456 dig = 6 5 4 3 digd = 6543 x2 = 3087 n1 = 3087 dig = 0 0 0 0 rem = 7 dig = 7 0 0 0 n1 = 308 rem = 8 dig = 7 8 0 0 n1 = 30 rem = 0 dig = 7 8 0 0 n1 = 3 rem = 3 dig = 7 8 0 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 3 7 8 diga = 378 dig = 8 7 3 0 digd = 8730 x2 = 8352 n1 = 8352 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 835 rem = 5 dig = 2 5 0 0 n1 = 83 rem = 3 dig = 2 5 3 0 n1 = 8 rem = 8 dig = 2 5 3 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 3 5 8 diga = 2358 dig = 8 5 3 2 digd = 8532 x2 = 6174

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

dig = 0 0 0 0 rem = 0 dig = 0 0 0 0 n1 = 808 rem = 8 dig = 0 8 0 0 n1 = 80 rem = 0 dig = 0 8 0 0 n1 = 8 rem = 8 dig = 0 8 0 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 0 0 8 8 diga = 88 dig = 8 8 0 0 digd = 8800 x2 = 8712 n1 = 8712 dig = 0 0 0 0 rem = 2 dig = 2 0 0 0 n1 = 871 rem = 1 dig = 2 1 0 0 n1 = 87 rem = 7 dig = 2 1 7 0 n1 = 8 rem = 8 dig = 2 1 7 8 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 2 7 8 diga = 1278 dig = 8 7 2 1 digd = 8721 x2 = 7443 n1 = 7443 dig = 0 0 0 0 rem = 3 dig = 3 0 0 0 n1 = 744 rem = 4 dig = 3 4 0 0 n1 = 74 rem = 4 dig = 3 4 4 0 n1 = 7 rem = 7 dig = 3 4 4 7 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 3 4 4 7 diga = 3447 dig = 7 4 4 3 digd = 7443 x2 = 3996 n1 = 3996 dig = 0 0 0 0 rem = 6 dig = 6 0 0 0 n1 = 399 rem = 9 dig = 6 9 0 0 n1 = 39 rem = 9 dig = 6 9 9 0 n1 = 3 rem = 3 dig = 6 9 9 3 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 3 6 9 9 diga = 3699 dig = 9 9 6 3 digd = 9963 x2 = 6264 n1 = 6264 dig = 0 0 0 0 rem = 4 dig = 4 0 0 0 n1 = 626 rem = 6 dig = 4 6 0 0 n1 = 62 rem = 2 dig = 4 6 2 0 n1 = 6 rem = 6 dig = 4 6 2 6 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 2 4 6 6 diga = 2466 dig = 6 6 4 2 digd = 6642 x2 = 4176 n1 = 4176 dig = 0 0 0 0 rem = 6 dig = 6 0 0 0 n1 = 417 rem = 7 dig = 6 7 0 0 n1 = 41 rem = 1 dig = 6 7 1 0 n1 = 4 rem = 4 dig = 6 7 1 4 n1 = 0 x1 = 1000 mul = 0 0 0 0 mul = 1000 0 0 0 mul = 1000 100 0 0 mul = 1000 100 10 0 mul = 1000 100 10 1 dig = 1 4 6 7 diga = 1467 dig = 7 6 4 1 digd = 7641 x2 = 6174