Cody

# Problem 166. Kaprekar numbers

Solution 807967

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

l = 3 sqr = 495616 ls = 6 sum = 1111

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

x = 9 tf_correct = 1 l = 1 sqr = 81 ls = 2 sum = 9

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

x = 45 tf_correct = 1 l = 2 sqr = 2025 ls = 4 sum = 45

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

x = 55 tf_correct = 1 l = 2 sqr = 3025 ls = 4 sum = 55

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

x = 99 tf_correct = 1 l = 2 sqr = 9801 ls = 4 sum = 99

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

x = 297 tf_correct = 1 l = 3 sqr = 88209 ls = 5 sum = 297

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

x = 703 tf_correct = 1 l = 3 sqr = 494209 ls = 6 sum = 703

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

x = 999 tf_correct = 1 l = 3 sqr = 998001 ls = 6 sum = 999

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

x = 2223 tf_correct = 1 l = 4 sqr = 4941729 ls = 7 sum = 2223

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

x = 2728 tf_correct = 1 l = 4 sqr = 7441984 ls = 7 sum = 2728

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

x = 4950 tf_correct = 1 l = 4 sqr = 24502500 ls = 8 sum = 4950

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

x = 5050 tf_correct = 1 l = 4 sqr = 25502500 ls = 8 sum = 5050

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

x = 7272 tf_correct = 1 l = 4 sqr = 52881984 ls = 8 sum = 7272

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

x = 7777 tf_correct = 1 l = 4 sqr = 60481729 ls = 8 sum = 7777

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

x = 9999 tf_correct = 1 l = 4 sqr = 99980001 ls = 8 sum = 9999

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

x = 17344 tf_correct = 1 l = 5 sqr = 300814336 ls = 9 sum = 17344

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

x = 22222 tf_correct = 1 l = 5 sqr = 493817284 ls = 9 sum = 22222

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

x = 77778 tf_correct = 1 l = 5 sqr = 6049417284 ls = 10 sum = 77778

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

x = 82656 tf_correct = 1 l = 5 sqr = 6832014336 ls = 10 sum = 82656

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

x = 95121 tf_correct = 1 l = 5 sqr = 9048004641 ls = 10 sum = 95121

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

x = 99999 tf_correct = 1 l = 5 sqr = 9999800001 ls = 10 sum = 99999

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

x = 142857 tf_correct = 1 l = 6 sqr = 20408122449 ls = 11 sum = 142857

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

x = 148149 tf_correct = 1 l = 6 sqr = 21948126201 ls = 11 sum = 148149

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

x = 181819 tf_correct = 1 l = 6 sqr = 33058148761 ls = 11 sum = 181819

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

x = 187110 tf_correct = 1 l = 6 sqr = 35010152100 ls = 11 sum = 187110

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

x = 208495 tf_correct = 1 l = 6 sqr = 43470165025 ls = 11 sum = 208495

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

x = 318682 tf_correct = 1 l = 6 sqr = 101558217124 ls = 12 sum = 318682

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

x = 329967 tf_correct = 1 l = 6 sqr = 108878221089 ls = 12 sum = 329967

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

x = 351352 tf_correct = 1 l = 6 sqr = 123448227904 ls = 12 sum = 351352

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

x = 356643 tf_correct = 1 l = 6 sqr = 127194229449 ls = 12 sum = 356643

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

x = 390313 tf_correct = 1 l = 6 sqr = 152344237969 ls = 12 sum = 390313

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

x = 461539 tf_correct = 1 l = 6 sqr = 213018248521 ls = 12 sum = 461539

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

x = 466830 tf_correct = 1 l = 6 sqr = 217930248900 ls = 12 sum = 466830

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

x = 499500 tf_correct = 1 l = 6 sqr = 249500250000 ls = 12 sum = 499500

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

x = 500500 tf_correct = 1 l = 6 sqr = 250500250000 ls = 12 sum = 500500

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

x = 533170 tf_correct = 1 l = 6 sqr = 284270248900 ls = 12 sum = 533170

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

x = 538461 tf_correct = 1 l = 6 sqr = 289940248521 ls = 12 sum = 538461

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

x = 609687 tf_correct = 1 l = 6 sqr = 371718237969 ls = 12 sum = 609687

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

x = 643357 tf_correct = 1 l = 6 sqr = 413908229449 ls = 12 sum = 643357

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

x = 648648 tf_correct = 1 l = 6 sqr = 420744227904 ls = 12 sum = 648648

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

x = 670033 tf_correct = 1 l = 6 sqr = 448944221089 ls = 12 sum = 670033

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

x = 681318 tf_correct = 1 l = 6 sqr = 464194217124 ls = 12 sum = 681318

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

x = 681319 tf_correct = 0 l = 6 sqr = 464195579761 ls = 12 sum = 1043956

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

x = 681320 tf_correct = 0 l = 6 sqr = 464196942400 ls = 12 sum = 1406596