Cody

Problem 68. Kaprekar Steps

Solution 209700

Submitted on 27 Feb 2013 by bartekltg
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))

v = 2367 v = 2556 v = 3699 v = 2466 v = 1467 j = 5

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

v = 0003 v = 2799 v = 1377 v = 3456 v = 0378 v = 2358 j = 6

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

v = 0169 v = 1449 v = 2799 v = 1377 v = 3456 v = 0378 v = 2358 j = 7

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

v = 3333 j = Inf

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

v = 0001 v = 0999 v = 1899 v = 0288 v = 2358 j = 5

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

j = 0

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

v = 1234 v = 0378 v = 2358 j = 3

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

v = 1134 v = 1377 v = 3456 v = 0378 v = 2358 j = 5

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

v = 0088 v = 1278 v = 3447 v = 3699 v = 2466 v = 1467 j = 6

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!