Cody

Solution 2017195

Submitted on 13 Nov 2019 by Weiyang Zhang
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))

a = 2367 d = 7632 ans = 1×4 logical array 1 0 0 0 x = 5265 a = 2556 d = 6552 x = 3996 a = 3699 d = 9963 x = 6264 a = 2466 d = 6642 x = 4176 a = 1467 d = 7641

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

a = 3 d = 3 ans = logical 1 x = 2997 a = 2799 d = 9972 x = 7173 a = 1377 d = 7731 x = 6354 a = 3456 d = 6543 x = 3087 a = 378 d = 8730 x = 8352 a = 2358 d = 8532

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

a = 169 d = 961 ans = 1×3 logical array 1 0 0 x = 9441 a = 1449 d = 9441 x = 7992 a = 2799 d = 9972 x = 7173 a = 1377 d = 7731 x = 6354 a = 3456 d = 6543 x = 3087 a = 378 d = 8730 x = 8352 a = 2358 d = 8532

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

a = 3333 d = 3333 ans = 1×4 logical array 1 1 1 1

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

a = 1 d = 1 ans = logical 1 x = 999 a = 999 d = 999 x = 8991 a = 1899 d = 9981 x = 8082 a = 288 d = 8820 x = 8532 a = 2358 d = 8532

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

a = 1467 d = 7641 ans = 1×4 logical array 1 0 0 0 y = 0

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

a = 1234 d = 4321 ans = 1×4 logical array 1 0 0 0 x = 3087 a = 378 d = 8730 x = 8352 a = 2358 d = 8532

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

a = 1134 d = 4311 ans = 1×4 logical array 1 0 0 0 x = 3177 a = 1377 d = 7731 x = 6354 a = 3456 d = 6543 x = 3087 a = 378 d = 8730 x = 8352 a = 2358 d = 8532

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

a = 88 d = 8800 ans = 1×4 logical array 1 0 1 0 x = 8712 a = 1278 d = 8721 x = 7443 a = 3447 d = 7443 x = 3996 a = 3699 d = 9963 x = 6264 a = 2466 d = 6642 x = 4176 a = 1467 d = 7641