Cody

Solution 1986228

Submitted on 22 Oct 2019 by Harsh Patel
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))

str = '3276' num1 = '2367' num2 = '7632' x = 5265 y = 1 str = '5265' num1 = '2556' num2 = '6552' x = 3996 y = 2 str = '3996' num1 = '3699' num2 = '9963' x = 6264 y = 3 str = '6264' num1 = '2466' num2 = '6642' x = 4176 y = 4 str = '4176' num1 = '1467' num2 = '7641' x = 6174 y = 5

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

str = '0003' num1 = '0003' num2 = '3000' x = 2997 y = 1 str = '2997' num1 = '2799' num2 = '9972' x = 7173 y = 2 str = '7173' num1 = '1377' num2 = '7731' x = 6354 y = 3 str = '6354' num1 = '3456' num2 = '6543' x = 3087 y = 4 str = '3087' num1 = '0378' num2 = '8730' x = 8352 y = 5 str = '8352' num1 = '2358' num2 = '8532' x = 6174 y = 6

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

str = '0691' num1 = '0169' num2 = '9610' x = 9441 y = 1 str = '9441' num1 = '1449' num2 = '9441' x = 7992 y = 2 str = '7992' num1 = '2799' num2 = '9972' x = 7173 y = 3 str = '7173' num1 = '1377' num2 = '7731' x = 6354 y = 4 str = '6354' num1 = '3456' num2 = '6543' x = 3087 y = 5 str = '3087' num1 = '0378' num2 = '8730' x = 8352 y = 6 str = '8352' num1 = '2358' num2 = '8532' x = 6174 y = 7

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

str = '3333' num1 = '3333' num2 = '3333' x = 0 y = 1 y = Inf

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

str = '0001' num1 = '0001' num2 = '1000' x = 999 y = 1 str = '0999' num1 = '0999' num2 = '9990' x = 8991 y = 2 str = '8991' num1 = '1899' num2 = '9981' x = 8082 y = 3 str = '8082' num1 = '0288' num2 = '8820' x = 8532 y = 4 str = '8532' num1 = '2358' num2 = '8532' x = 6174 y = 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))

str = '1234' num1 = '1234' num2 = '4321' x = 3087 y = 1 str = '3087' num1 = '0378' num2 = '8730' x = 8352 y = 2 str = '8352' num1 = '2358' num2 = '8532' x = 6174 y = 3

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

str = '3141' num1 = '1134' num2 = '4311' x = 3177 y = 1 str = '3177' num1 = '1377' num2 = '7731' x = 6354 y = 2 str = '6354' num1 = '3456' num2 = '6543' x = 3087 y = 3 str = '3087' num1 = '0378' num2 = '8730' x = 8352 y = 4 str = '8352' num1 = '2358' num2 = '8532' x = 6174 y = 5

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

str = '8080' num1 = '0088' num2 = '8800' x = 8712 y = 1 str = '8712' num1 = '1278' num2 = '8721' x = 7443 y = 2 str = '7443' num1 = '3447' num2 = '7443' x = 3996 y = 3 str = '3996' num1 = '3699' num2 = '9963' x = 6264 y = 4 str = '6264' num1 = '2466' num2 = '6642' x = 4176 y = 5 str = '4176' num1 = '1467' num2 = '7641' x = 6174 y = 6

Suggested Problems

More from this Author95