Cody

# Problem 166. Kaprekar numbers

Solution 812127

Submitted on 22 Jan 2016 by David Schafer
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 = 704; tf_correct = false; assert(isequal(kap(x),tf_correct))

k = 495616 xx = 4 9 5 6 1 6 left = 4 right = 9 5 6 1 6 left = 4 9 right = 5 6 1 6 left = 4 9 5 right = 6 1 6 left = 4 9 5 6 right = 1 6 left = 4 9 5 6 1 right = 6

2   Pass
%% x = 9 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 9 tf_correct = 1 k = 81 xx = 8 1 left = 8 right = 1 tf = 1

3   Pass
%% x = 45 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 45 tf_correct = 1 k = 2025 xx = 2 0 2 5 left = 2 right = 0 2 5 left = 2 0 right = 2 5 tf = 1 left = 2 0 2 right = 5

4   Pass
%% x = 55 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 55 tf_correct = 1 k = 3025 xx = 3 0 2 5 left = 3 right = 0 2 5 left = 3 0 right = 2 5 tf = 1 left = 3 0 2 right = 5

5   Pass
%% x = 99 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 99 tf_correct = 1 k = 9801 xx = 9 8 0 1 left = 9 right = 8 0 1 left = 9 8 right = 0 1 tf = 1 left = 9 8 0 right = 1

6   Pass
%% x = 297 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 297 tf_correct = 1 k = 88209 xx = 8 8 2 0 9 left = 8 right = 8 2 0 9 left = 8 8 right = 2 0 9 tf = 1 left = 8 8 2 right = 0 9 left = 8 8 2 0 right = 9

7   Pass
%% x = 703 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 703 tf_correct = 1 k = 494209 xx = 4 9 4 2 0 9 left = 4 right = 9 4 2 0 9 left = 4 9 right = 4 2 0 9 left = 4 9 4 right = 2 0 9 tf = 1 left = 4 9 4 2 right = 0 9 left = 4 9 4 2 0 right = 9

8   Pass
%% x = 999 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 999 tf_correct = 1 k = 998001 xx = 9 9 8 0 0 1 left = 9 right = 9 8 0 0 1 left = 9 9 right = 8 0 0 1 left = 9 9 8 right = 0 0 1 tf = 1 left = 9 9 8 0 right = 0 1 left = 9 9 8 0 0 right = 1

9   Pass
%% x = 2223 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 2223 tf_correct = 1 k = 4941729 xx = 4 9 4 1 7 2 9 left = 4 right = 9 4 1 7 2 9 left = 4 9 right = 4 1 7 2 9 left = 4 9 4 right = 1 7 2 9 tf = 1 left = 4 9 4 1 right = 7 2 9 left = 4 9 4 1 7 right = 2 9 left = 4 9 4 1 7 2 right = 9

10   Pass
%% x = 2728 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 2728 tf_correct = 1 k = 7441984 xx = 7 4 4 1 9 8 4 left = 7 right = 4 4 1 9 8 4 left = 7 4 right = 4 1 9 8 4 left = 7 4 4 right = 1 9 8 4 tf = 1 left = 7 4 4 1 right = 9 8 4 left = 7 4 4 1 9 right = 8 4 left = 7 4 4 1 9 8 right = 4

11   Pass
%% x = 4950 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 4950 tf_correct = 1 k = 24502500 xx = 2 4 5 0 2 5 0 0 left = 2 right = 4 5 0 2 5 0 0 left = 2 4 right = 5 0 2 5 0 0 left = 2 4 5 right = 0 2 5 0 0 left = 2 4 5 0 right = 2 5 0 0 tf = 1 left = 2 4 5 0 2 right = 5 0 0 left = 2 4 5 0 2 5 right = 0 0 left = 2 4 5 0 2 5 0 right = 0

12   Pass
%% x = 5050 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 5050 tf_correct = 1 k = 25502500 xx = 2 5 5 0 2 5 0 0 left = 2 right = 5 5 0 2 5 0 0 left = 2 5 right = 5 0 2 5 0 0 left = 2 5 5 right = 0 2 5 0 0 left = 2 5 5 0 right = 2 5 0 0 tf = 1 left = 2 5 5 0 2 right = 5 0 0 left = 2 5 5 0 2 5 right = 0 0 left = 2 5 5 0 2 5 0 right = 0

13   Pass
%% x = 7272 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 7272 tf_correct = 1 k = 52881984 xx = 5 2 8 8 1 9 8 4 left = 5 right = 2 8 8 1 9 8 4 left = 5 2 right = 8 8 1 9 8 4 left = 5 2 8 right = 8 1 9 8 4 left = 5 2 8 8 right = 1 9 8 4 tf = 1 left = 5 2 8 8 1 right = 9 8 4 left = 5 2 8 8 1 9 right = 8 4 left = 5 2 8 8 1 9 8 right = 4

14   Pass
%% x = 7777 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 7777 tf_correct = 1 k = 60481729 xx = 6 0 4 8 1 7 2 9 left = 6 right = 0 4 8 1 7 2 9 left = 6 0 right = 4 8 1 7 2 9 left = 6 0 4 right = 8 1 7 2 9 left = 6 0 4 8 right = 1 7 2 9 tf = 1 left = 6 0 4 8 1 right = 7 2 9 left = 6 0 4 8 1 7 right = 2 9 left = 6 0 4 8 1 7 2 right = 9

15   Pass
%% x = 9999 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 9999 tf_correct = 1 k = 99980001 xx = 9 9 9 8 0 0 0 1 left = 9 right = 9 9 8 0 0 0 1 left = 9 9 right = 9 8 0 0 0 1 left = 9 9 9 right = 8 0 0 0 1 left = 9 9 9 8 right = 0 0 0 1 tf = 1 left = 9 9 9 8 0 right = 0 0 1 left = 9 9 9 8 0 0 right = 0 1 left = 9 9 9 8 0 0 0 right = 1

16   Pass
%% x = 17344 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 17344 tf_correct = 1 k = 300814336 xx = 3 0 0 8 1 4 3 3 6 left = 3 right = 0 0 8 1 4 3 3 6 left = 3 0 right = 0 8 1 4 3 3 6 left = 3 0 0 right = 8 1 4 3 3 6 left = 3 0 0 8 right = 1 4 3 3 6 tf = 1 left = 3 0 0 8 1 right = 4 3 3 6 left = 3 0 0 8 1 4 right = 3 3 6 left = 3 0 0 8 1 4 3 right = 3 6 left = 3 0 0 8 1 4 3 3 right = 6

17   Pass
%% x = 22222 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 22222 tf_correct = 1 k = 493817284 xx = 4 9 3 8 1 7 2 8 4 left = 4 right = 9 3 8 1 7 2 8 4 left = 4 9 right = 3 8 1 7 2 8 4 left = 4 9 3 right = 8 1 7 2 8 4 left = 4 9 3 8 right = 1 7 2 8 4 tf = 1 left = 4 9 3 8 1 right = 7 2 8 4 left = 4 9 3 8 1 7 right = 2 8 4 left = 4 9 3 8 1 7 2 right = 8 4 left = 4 9 3 8 1 7 2 8 right = 4

18   Pass
%% x = 77778 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 77778 tf_correct = 1 k = 6.0494e+09 xx = 6 0 4 9 4 1 7 2 8 4 left = 6 right = 0 4 9 4 1 7 2 8 4 left = 6 0 right = 4 9 4 1 7 2 8 4 left = 6 0 4 right = 9 4 1 7 2 8 4 left = 6 0 4 9 right = 4 1 7 2 8 4 left = 6 0 4 9 4 right = 1 7 2 8 4 tf = 1 left = 6 0 4 9 4 1 right = 7 2 8 4 left = 6 0 4 9 4 1 7 right = 2 8 4 left = 6 0 4 9 4 1 7 2 right = 8 4 left = 6 0 4 9 4 1 7 2 8 right = 4

19   Pass
%% x = 82656 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 82656 tf_correct = 1 k = 6.8320e+09 xx = 6 8 3 2 0 1 4 3 3 6 left = 6 right = 8 3 2 0 1 4 3 3 6 left = 6 8 right = 3 2 0 1 4 3 3 6 left = 6 8 3 right = 2 0 1 4 3 3 6 left = 6 8 3 2 right = 0 1 4 3 3 6 left = 6 8 3 2 0 right = 1 4 3 3 6 tf = 1 left = 6 8 3 2 0 1 right = 4 3 3 6 left = 6 8 3 2 0 1 4 right = 3 3 6 left = 6 8 3 2 0 1 4 3 right = 3 6 left = 6 8 3 2 0 1 4 3 3 right = 6

20   Pass
%% x = 95121 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 95121 tf_correct = 1 k = 9.0480e+09 xx = 9 0 4 8 0 0 4 6 4 1 left = 9 right = 0 4 8 0 0 4 6 4 1 left = 9 0 right = 4 8 0 0 4 6 4 1 left = 9 0 4 right = 8 0 0 4 6 4 1 left = 9 0 4 8 right = 0 0 4 6 4 1 left = 9 0 4 8 0 right = 0 4 6 4 1 tf = 1 left = 9 0 4 8 0 0 right = 4 6 4 1 left = 9 0 4 8 0 0 4 right = 6 4 1 left = 9 0 4 8 0 0 4 6 right = 4 1 left = 9 0 4 8 0 0 4 6 4 right = 1

21   Pass
%% x = 99999 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 99999 tf_correct = 1 k = 9.9998e+09 xx = 9 9 9 9 8 0 0 0 0 1 left = 9 right = 9 9 9 8 0 0 0 0 1 left = 9 9 right = 9 9 8 0 0 0 0 1 left = 9 9 9 right = 9 8 0 0 0 0 1 left = 9 9 9 9 right = 8 0 0 0 0 1 left = 9 9 9 9 8 right = 0 0 0 0 1 tf = 1 left = 9 9 9 9 8 0 right = 0 0 0 1 left = 9 9 9 9 8 0 0 right = 0 0 1 left = 9 9 9 9 8 0 0 0 right = 0 1 left = 9 9 9 9 8 0 0 0 0 right = 1

22   Pass
%% x = 142857 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 142857 tf_correct = 1 k = 2.0408e+10 xx = 2 0 4 0 8 1 2 2 4 4 9 left = 2 right = 0 4 0 8 1 2 2 4 4 9 left = 2 0 right = 4 0 8 1 2 2 4 4 9 left = 2 0 4 right = 0 8 1 2 2 4 4 9 left = 2 0 4 0 right = 8 1 2 2 4 4 9 left = 2 0 4 0 8 right = 1 2 2 4 4 9 tf = 1 left = 2 0 4 0 8 1 right = 2 2 4 4 9 left = 2 0 4 0 8 1 2 right = 2 4 4 9 left = 2 0 4 0 8 1 2 2 right = 4 4 9 left = 2 0 4 0 8 1 2 2 4 right = 4 9 left = 2 0 4 0 8 1 2 2 4 4 right = 9

23   Pass
%% x = 148149 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 148149 tf_correct = 1 k = 2.1948e+10 xx = 2 1 9 4 8 1 2 6 2 0 1 left = 2 right = 1 9 4 8 1 2 6 2 0 1 left = 2 1 right = 9 4 8 1 2 6 2 0 1 left = 2 1 9 right = 4 8 1 2 6 2 0 1 left = 2 1 9 4 right = 8 1 2 6 2 0 1 left = 2 1 9 4 8 right = 1 2 6 2 0 1 tf = 1 left = 2 1 9 4 8 1 right = 2 6 2 0 1 left = 2 1 9 4 8 1 2 right = 6 2 0 1 left = 2 1 9 4 8 1 2 6 right = 2 0 1 left = 2 1 9 4 8 1 2 6 2 right = 0 1 left = 2 1 9 4 8 1 2 6 2 0 right = 1

24   Pass
%% x = 181819 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 181819 tf_correct = 1 k = 3.3058e+10 xx = 3 3 0 5 8 1 4 8 7 6 1 left = 3 right = 3 0 5 8 1 4 8 7 6 1 left = 3 3 right = 0 5 8 1 4 8 7 6 1 left = 3 3 0 right = 5 8 1 4 8 7 6 1 left = 3 3 0 5 right = 8 1 4 8 7 6 1 left = 3 3 0 5 8 right = 1 4 8 7 6 1 tf = 1 left = 3 3 0 5 8 1 right = 4 8 7 6 1 left = 3 3 0 5 8 1 4 right = 8 7 6 1 left = 3 3 0 5 8 1 4 8 right = 7 6 1 left = 3 3 0 5 8 1 4 8 7 right = 6 1 left = 3 3 0 5 8 1 4 8 7 6 right = 1

25   Pass
%% x = 187110 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 187110 tf_correct = 1 k = 3.5010e+10 xx = 3 5 0 1 0 1 5 2 1 0 0 left = 3 right = 5 0 1 0 1 5 2 1 0 0 left = 3 5 right = 0 1 0 1 5 2 1 0 0 left = 3 5 0 right = 1 0 1 5 2 1 0 0 left = 3 5 0 1 right = 0 1 5 2 1 0 0 left = 3 5 0 1 0 right = 1 5 2 1 0 0 tf = 1 left = 3 5 0 1 0 1 right = 5 2 1 0 0 left = 3 5 0 1 0 1 5 right = 2 1 0 0 left = 3 5 0 1 0 1 5 2 right = 1 0 0 left = 3 5 0 1 0 1 5 2 1 right = 0 0 left = 3 5 0 1 0 1 5 2 1 0 right = 0

26   Pass
%% x = 208495 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 208495 tf_correct = 1 k = 4.3470e+10 xx = 4 3 4 7 0 1 6 5 0 2 5 left = 4 right = 3 4 7 0 1 6 5 0 2 5 left = 4 3 right = 4 7 0 1 6 5 0 2 5 left = 4 3 4 right = 7 0 1 6 5 0 2 5 left = 4 3 4 7 right = 0 1 6 5 0 2 5 left = 4 3 4 7 0 right = 1 6 5 0 2 5 tf = 1 left = 4 3 4 7 0 1 right = 6 5 0 2 5 left = 4 3 4 7 0 1 6 right = 5 0 2 5 left = 4 3 4 7 0 1 6 5 right = 0 2 5 left = 4 3 4 7 0 1 6 5 0 right = 2 5 left = 4 3 4 7 0 1 6 5 0 2 right = 5

27   Pass
%% x = 318682 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 318682 tf_correct = 1 k = 1.0156e+11 xx = 1 0 1 5 5 8 2 1 7 1 2 4 left = 1 right = 0 1 5 5 8 2 1 7 1 2 4 left = 1 0 right = 1 5 5 8 2 1 7 1 2 4 left = 1 0 1 right = 5 5 8 2 1 7 1 2 4 left = 1 0 1 5 right = 5 8 2 1 7 1 2 4 left = 1 0 1 5 5 right = 8 2 1 7 1 2 4 left = 1 0 1 5 5 8 right = 2 1 7 1 2 4 tf = 1 left = 1 0 1 5 5 8 2 right = 1 7 1 2 4 left = 1 0 1 5 5 8 2 1 right = 7 1 2 4 left = 1 0 1 5 5 8 2 1 7 right = 1 2 4 left = 1 0 1 5 5 8 2 1 7 1 right = 2 4 left = 1 0 1 5 5 8 2 1 7 1 2 right = 4

28   Pass
%% x = 329967 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 329967 tf_correct = 1 k = 1.0888e+11 xx = 1 0 8 8 7 8 2 2 1 0 8 9 left = 1 right = 0 8 8 7 8 2 2 1 0 8 9 left = 1 0 right = 8 8 7 8 2 2 1 0 8 9 left = 1 0 8 right = 8 7 8 2 2 1 0 8 9 left = 1 0 8 8 right = 7 8 2 2 1 0 8 9 left = 1 0 8 8 7 right = 8 2 2 1 0 8 9 left = 1 0 8 8 7 8 right = 2 2 1 0 8 9 tf = 1 left = 1 0 8 8 7 8 2 right = 2 1 0 8 9 left = 1 0 8 8 7 8 2 2 right = 1 0 8 9 left = 1 0 8 8 7 8 2 2 1 right = 0 8 9 left = 1 0 8 8 7 8 2 2 1 0 right = 8 9 left = 1 0 8 8 7 8 2 2 1 0 8 right = 9

29   Pass
%% x = 351352 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 351352 tf_correct = 1 k = 1.2345e+11 xx = 1 2 3 4 4 8 2 2 7 9 0 4 left = 1 right = 2 3 4 4 8 2 2 7 9 0 4 left = 1 2 right = 3 4 4 8 2 2 7 9 0 4 left = 1 2 3 right = 4 4 8 2 2 7 9 0 4 left = 1 2 3 4 right = 4 8 2 2 7 9 0 4 left = 1 2 3 4 4 right = 8 2 2 7 9 0 4 left = 1 2 3 4 4 8 right = 2 2 7 9 0 4 tf = 1 left = 1 2 3 4 4 8 2 right = 2 7 9 0 4 left = 1 2 3 4 4 8 2 2 right = 7 9 0 4 left = 1 2 3 4 4 8 2 2 7 right = 9 0 4 left = 1 2 3 4 4 8 2 2 7 9 right = 0 4 left = 1 2 3 4 4 8 2 2 7 9 0 right = 4

30   Pass
%% x = 356643 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 356643 tf_correct = 1 k = 1.2719e+11 xx = 1 2 7 1 9 4 2 2 9 4 4 9 left = 1 right = 2 7 1 9 4 2 2 9 4 4 9 left = 1 2 right = 7 1 9 4 2 2 9 4 4 9 left = 1 2 7 right = 1 9 4 2 2 9 4 4 9 left = 1 2 7 1 right = 9 4 2 2 9 4 4 9 left = 1 2 7 1 9 right = 4 2 2 9 4 4 9 left = 1 2 7 1 9 4 right = 2 2 9 4 4 9 tf = 1 left = 1 2 7 1 9 4 2 right = 2 9 4 4 9 left = 1 2 7 1 9 4 2 2 right = 9 4 4 9 left = 1 2 7 1 9 4 2 2 9 right = 4 4 9 left = 1 2 7 1 9 4 2 2 9 4 right = 4 9 left = 1 2 7 1 9 4 2 2 9 4 4 right = 9

31   Pass
%% x = 390313 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 390313 tf_correct = 1 k = 1.5234e+11 xx = 1 5 2 3 4 4 2 3 7 9 6 9 left = 1 right = 5 2 3 4 4 2 3 7 9 6 9 left = 1 5 right = 2 3 4 4 2 3 7 9 6 9 left = 1 5 2 right = 3 4 4 2 3 7 9 6 9 left = 1 5 2 3 right = 4 4 2 3 7 9 6 9 left = 1 5 2 3 4 right = 4 2 3 7 9 6 9 left = 1 5 2 3 4 4 right = 2 3 7 9 6 9 tf = 1 left = 1 5 2 3 4 4 2 right = 3 7 9 6 9 left = 1 5 2 3 4 4 2 3 right = 7 9 6 9 left = 1 5 2 3 4 4 2 3 7 right = 9 6 9 left = 1 5 2 3 4 4 2 3 7 9 right = 6 9 left = 1 5 2 3 4 4 2 3 7 9 6 right = 9

32   Pass
%% x = 461539 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 461539 tf_correct = 1 k = 2.1302e+11 xx = 2 1 3 0 1 8 2 4 8 5 2 1 left = 2 right = 1 3 0 1 8 2 4 8 5 2 1 left = 2 1 right = 3 0 1 8 2 4 8 5 2 1 left = 2 1 3 right = 0 1 8 2 4 8 5 2 1 left = 2 1 3 0 right = 1 8 2 4 8 5 2 1 left = 2 1 3 0 1 right = 8 2 4 8 5 2 1 left = 2 1 3 0 1 8 right = 2 4 8 5 2 1 tf = 1 left = 2 1 3 0 1 8 2 right = 4 8 5 2 1 left = 2 1 3 0 1 8 2 4 right = 8 5 2 1 left = 2 1 3 0 1 8 2 4 8 right = 5 2 1 left = 2 1 3 0 1 8 2 4 8 5 right = 2 1 left = 2 1 3 0 1 8 2 4 8 5 2 right = 1

33   Pass
%% x = 466830 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 466830 tf_correct = 1 k = 2.1793e+11 xx = 2 1 7 9 3 0 2 4 8 9 0 0 left = 2 right = 1 7 9 3 0 2 4 8 9 0 0 left = 2 1 right = 7 9 3 0 2 4 8 9 0 0 left = 2 1 7 right = 9 3 0 2 4 8 9 0 0 left = 2 1 7 9 right = 3 0 2 4 8 9 0 0 left = 2 1 7 9 3 right = 0 2 4 8 9 0 0 left = 2 1 7 9 3 0 right = 2 4 8 9 0 0 tf = 1 left = 2 1 7 9 3 0 2 right = 4 8 9 0 0 left = 2 1 7 9 3 0 2 4 right = 8 9 0 0 left = 2 1 7 9 3 0 2 4 8 right = 9 0 0 left = 2 1 7 9 3 0 2 4 8 9 right = 0 0 left = 2 1 7 9 3 0 2 4 8 9 0 right = 0

34   Pass
%% x = 499500 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 499500 tf_correct = 1 k = 2.4950e+11 xx = 2 4 9 5 0 0 2 5 0 0 0 0 left = 2 right = 4 9 5 0 0 2 5 0 0 0 0 left = 2 4 right = 9 5 0 0 2 5 0 0 0 0 left = 2 4 9 right = 5 0 0 2 5 0 0 0 0 left = 2 4 9 5 right = 0 0 2 5 0 0 0 0 left = 2 4 9 5 0 right = 0 2 5 0 0 0 0 left = 2 4 9 5 0 0 right = 2 5 0 0 0 0 tf = 1 left = 2 4 9 5 0 0 2 right = 5 0 0 0 0 left = 2 4 9 5 0 0 2 5 right = 0 0 0 0 left = 2 4 9 5 0 0 2 5 0 right = 0 0 0 left = 2 4 9 5 0 0 2 5 0 0 right = 0 0 left = 2 4 9 5 0 0 2 5 0 0 0 right = 0

35   Pass
%% x = 500500 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 500500 tf_correct = 1 k = 2.5050e+11 xx = 2 5 0 5 0 0 2 5 0 0 0 0 left = 2 right = 5 0 5 0 0 2 5 0 0 0 0 left = 2 5 right = 0 5 0 0 2 5 0 0 0 0 left = 2 5 0 right = 5 0 0 2 5 0 0 0 0 left = 2 5 0 5 right = 0 0 2 5 0 0 0 0 left = 2 5 0 5 0 right = 0 2 5 0 0 0 0 left = 2 5 0 5 0 0 right = 2 5 0 0 0 0 tf = 1 left = 2 5 0 5 0 0 2 right = 5 0 0 0 0 left = 2 5 0 5 0 0 2 5 right = 0 0 0 0 left = 2 5 0 5 0 0 2 5 0 right = 0 0 0 left = 2 5 0 5 0 0 2 5 0 0 right = 0 0 left = 2 5 0 5 0 0 2 5 0 0 0 right = 0

36   Pass
%% x = 533170 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 533170 tf_correct = 1 k = 2.8427e+11 xx = 2 8 4 2 7 0 2 4 8 9 0 0 left = 2 right = 8 4 2 7 0 2 4 8 9 0 0 left = 2 8 right = 4 2 7 0 2 4 8 9 0 0 left = 2 8 4 right = 2 7 0 2 4 8 9 0 0 left = 2 8 4 2 right = 7 0 2 4 8 9 0 0 left = 2 8 4 2 7 right = 0 2 4 8 9 0 0 left = 2 8 4 2 7 0 right = 2 4 8 9 0 0 tf = 1 left = 2 8 4 2 7 0 2 right = 4 8 9 0 0 left = 2 8 4 2 7 0 2 4 right = 8 9 0 0 left = 2 8 4 2 7 0 2 4 8 right = 9 0 0 left = 2 8 4 2 7 0 2 4 8 9 right = 0 0 left = 2 8 4 2 7 0 2 4 8 9 0 right = 0

37   Pass
%% x = 538461 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 538461 tf_correct = 1 k = 2.8994e+11 xx = 2 8 9 9 4 0 2 4 8 5 2 1 left = 2 right = 8 9 9 4 0 2 4 8 5 2 1 left = 2 8 right = 9 9 4 0 2 4 8 5 2 1 left = 2 8 9 right = 9 4 0 2 4 8 5 2 1 left = 2 8 9 9 right = 4 0 2 4 8 5 2 1 left = 2 8 9 9 4 right = 0 2 4 8 5 2 1 left = 2 8 9 9 4 0 right = 2 4 8 5 2 1 tf = 1 left = 2 8 9 9 4 0 2 right = 4 8 5 2 1 left = 2 8 9 9 4 0 2 4 right = 8 5 2 1 left = 2 8 9 9 4 0 2 4 8 right = 5 2 1 left = 2 8 9 9 4 0 2 4 8 5 right = 2 1 left = 2 8 9 9 4 0 2 4 8 5 2 right = 1

38   Pass
%% x = 609687 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 609687 tf_correct = 1 k = 3.7172e+11 xx = 3 7 1 7 1 8 2 3 7 9 6 9 left = 3 right = 7 1 7 1 8 2 3 7 9 6 9 left = 3 7 right = 1 7 1 8 2 3 7 9 6 9 left = 3 7 1 right = 7 1 8 2 3 7 9 6 9 left = 3 7 1 7 right = 1 8 2 3 7 9 6 9 left = 3 7 1 7 1 right = 8 2 3 7 9 6 9 left = 3 7 1 7 1 8 right = 2 3 7 9 6 9 tf = 1 left = 3 7 1 7 1 8 2 right = 3 7 9 6 9 left = 3 7 1 7 1 8 2 3 right = 7 9 6 9 left = 3 7 1 7 1 8 2 3 7 right = 9 6 9 left = 3 7 1 7 1 8 2 3 7 9 right = 6 9 left = 3 7 1 7 1 8 2 3 7 9 6 right = 9

39   Pass
%% x = 643357 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 643357 tf_correct = 1 k = 4.1391e+11 xx = 4 1 3 9 0 8 2 2 9 4 4 9 left = 4 right = 1 3 9 0 8 2 2 9 4 4 9 left = 4 1 right = 3 9 0 8 2 2 9 4 4 9 left = 4 1 3 right = 9 0 8 2 2 9 4 4 9 left = 4 1 3 9 right = 0 8 2 2 9 4 4 9 left = 4 1 3 9 0 right = 8 2 2 9 4 4 9 left = 4 1 3 9 0 8 right = 2 2 9 4 4 9 tf = 1 left = 4 1 3 9 0 8 2 right = 2 9 4 4 9 left = 4 1 3 9 0 8 2 2 right = 9 4 4 9 left = 4 1 3 9 0 8 2 2 9 right = 4 4 9 left = 4 1 3 9 0 8 2 2 9 4 right = 4 9 left = 4 1 3 9 0 8 2 2 9 4 4 right = 9

40   Pass
%% x = 648648 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 648648 tf_correct = 1 k = 4.2074e+11 xx = 4 2 0 7 4 4 2 2 7 9 0 4 left = 4 right = 2 0 7 4 4 2 2 7 9 0 4 left = 4 2 right = 0 7 4 4 2 2 7 9 0 4 left = 4 2 0 right = 7 4 4 2 2 7 9 0 4 left = 4 2 0 7 right = 4 4 2 2 7 9 0 4 left = 4 2 0 7 4 right = 4 2 2 7 9 0 4 left = 4 2 0 7 4 4 right = 2 2 7 9 0 4 tf = 1 left = 4 2 0 7 4 4 2 right = 2 7 9 0 4 left = 4 2 0 7 4 4 2 2 right = 7 9 0 4 left = 4 2 0 7 4 4 2 2 7 right = 9 0 4 left = 4 2 0 7 4 4 2 2 7 9 right = 0 4 left = 4 2 0 7 4 4 2 2 7 9 0 right = 4

41   Pass
%% x = 670033 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 670033 tf_correct = 1 k = 4.4894e+11 xx = 4 4 8 9 4 4 2 2 1 0 8 9 left = 4 right = 4 8 9 4 4 2 2 1 0 8 9 left = 4 4 right = 8 9 4 4 2 2 1 0 8 9 left = 4 4 8 right = 9 4 4 2 2 1 0 8 9 left = 4 4 8 9 right = 4 4 2 2 1 0 8 9 left = 4 4 8 9 4 right = 4 2 2 1 0 8 9 left = 4 4 8 9 4 4 right = 2 2 1 0 8 9 tf = 1 left = 4 4 8 9 4 4 2 right = 2 1 0 8 9 left = 4 4 8 9 4 4 2 2 right = 1 0 8 9 left = 4 4 8 9 4 4 2 2 1 right = 0 8 9 left = 4 4 8 9 4 4 2 2 1 0 right = 8 9 left = 4 4 8 9 4 4 2 2 1 0 8 right = 9

42   Pass
%% x = 681318 tf_correct = true assert(isequal(kap(x),tf_correct))

x = 681318 tf_correct = 1 k = 4.6419e+11 xx = 4 6 4 1 9 4 2 1 7 1 2 4 left = 4 right = 6 4 1 9 4 2 1 7 1 2 4 left = 4 6 right = 4 1 9 4 2 1 7 1 2 4 left = 4 6 4 right = 1 9 4 2 1 7 1 2 4 left = 4 6 4 1 right = 9 4 2 1 7 1 2 4 left = 4 6 4 1 9 right = 4 2 1 7 1 2 4 left = 4 6 4 1 9 4 right = 2 1 7 1 2 4 tf = 1 left = 4 6 4 1 9 4 2 right = 1 7 1 2 4 left = 4 6 4 1 9 4 2 1 right = 7 1 2 4 left = 4 6 4 1 9 4 2 1 7 right = 1 2 4 left = 4 6 4 1 9 4 2 1 7 1 right = 2 4 left = 4 6 4 1 9 4 2 1 7 1 2 right = 4

43   Pass
%% x = 681319 tf_correct = false assert(isequal(kap(x),tf_correct))

x = 681319 tf_correct = 0 k = 4.6420e+11 xx = 4 6 4 1 9 5 5 7 9 7 6 1 left = 4 right = 6 4 1 9 5 5 7 9 7 6 1 left = 4 6 right = 4 1 9 5 5 7 9 7 6 1 left = 4 6 4 right = 1 9 5 5 7 9 7 6 1 left = 4 6 4 1 right = 9 5 5 7 9 7 6 1 left = 4 6 4 1 9 right = 5 5 7 9 7 6 1 left = 4 6 4 1 9 5 right = 5 7 9 7 6 1 left = 4 6 4 1 9 5 5 right = 7 9 7 6 1 left = 4 6 4 1 9 5 5 7 right = 9 7 6 1 left = 4 6 4 1 9 5 5 7 9 right = 7 6 1 left = 4 6 4 1 9 5 5 7 9 7 right = 6 1 left = 4 6 4 1 9 5 5 7 9 7 6 right = 1

44   Pass
%% x = 681320 tf_correct = false assert(isequal(kap(x),tf_correct))

x = 681320 tf_correct = 0 k = 4.6420e+11 xx = 4 6 4 1 9 6 9 4 2 4 0 0 left = 4 right = 6 4 1 9 6 9 4 2 4 0 0 left = 4 6 right = 4 1 9 6 9 4 2 4 0 0 left = 4 6 4 right = 1 9 6 9 4 2 4 0 0 left = 4 6 4 1 right = 9 6 9 4 2 4 0 0 left = 4 6 4 1 9 right = 6 9 4 2 4 0 0 left = 4 6 4 1 9 6 right = 9 4 2 4 0 0 left = 4 6 4 1 9 6 9 right = 4 2 4 0 0 left = 4 6 4 1 9 6 9 4 right = 2 4 0 0 left = 4 6 4 1 9 6 9 4 2 right = 4 0 0 left = 4 6 4 1 9 6 9 4 2 4 right = 0 0 left = 4 6 4 1 9 6 9 4 2 4 0 right = 0