Cody

# Problem 68. Kaprekar Steps

Solution 420140

Submitted on 19 Mar 2014 by Abdullah Caliskan
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))

r = 3276 H = [] g = 2367 k = 2367 p = 5265 g = 2556 k = 2556 p = 3996 g = 3699 k = 3699 p = 6264 g = 2466 k = 2466 p = 4176 g = 1467 k = 1467 p = 6174 hh = 5

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

r = 3 d = 2997 H = [] g = 2799 k = 2799 p = 7173 g = 1377 k = 1377 p = 6354 g = 3456 k = 3456 p = 3087 g = 0378 k = 378 p = 8352 g = 2358 k = 2358 p = 6174 hh = 5

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

r = 691 H = [] g = 169 k = 169 p = 792 g = 279 k = 279 p = 693 g = 369 k = 369 p = 594 g = 459 k = 459 p = 495 g = 459 k = 459 p = 495 g = 459 k = 459 p = 495 g = 459 k = 459 p = 495 g = 459 k = 459 p = 495 g = 459 k = 459 p = 495 g = 459 k = 459 p = 495 hh = 11

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

r = 3333 H = [] g = 3333 k = 3333 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 hh = 11

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

r = 1 d = 999 H = [] g = 999 k = 999 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 g = 0 k = 0 p = 0 hh = 11

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

r = 6174 H = [] g = 1467 k = 1467 p = 6174 hh = 1

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

r = 1234 H = [] g = 1234 k = 1234 p = 3087 g = 0378 k = 378 p = 8352 g = 2358 k = 2358 p = 6174 hh = 3

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

r = 3141 H = [] g = 1134 k = 1134 p = 3177 g = 1377 k = 1377 p = 6354 g = 3456 k = 3456 p = 3087 g = 0378 k = 378 p = 8352 g = 2358 k = 2358 p = 6174 hh = 5

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

r = 8080 H = [] g = 0088 k = 88 p = 8712 g = 1278 k = 1278 p = 7443 g = 3447 k = 3447 p = 3996 g = 3699 k = 3699 p = 6264 g = 2466 k = 2466 p = 4176 g = 1467 k = 1467 p = 6174 hh = 6

### Community Treasure Hunt

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

Start Hunting!