Cody

Problem 166. Kaprekar numbers

Solution 3178536

Submitted on 12 Oct 2020 by Paul Morant
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 = 16; tf_correct = false; assert(isequal(kap(x),tf_correct))

x2str = '256' len = 3 ans = logical 0

2   Pass
x = 704; tf_correct = false; assert(isequal(kap(x),tf_correct))

x2str = '495616' len = 6 ans = logical 0

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

x = 9 tf_correct = logical 1 x2str = '81' len = 2 ans = logical 1

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

x = 45 tf_correct = logical 1 x2str = '2025' len = 4 ans = logical 1

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

x = 55 tf_correct = logical 1 x2str = '3025' len = 4 ans = logical 1

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

x = 99 tf_correct = logical 1 x2str = '9801' len = 4 ans = logical 1

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

x = 297 tf_correct = logical 1 x2str = '88209' len = 5 ans = logical 1

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

x = 703 tf_correct = logical 1 x2str = '494209' len = 6 ans = logical 1

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

x = 999 tf_correct = logical 1 x2str = '998001' len = 6 ans = logical 1

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

x = 2223 tf_correct = logical 1 x2str = '4941729' len = 7 ans = logical 1

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

x = 2728 tf_correct = logical 1 x2str = '7441984' len = 7 ans = logical 1

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

x = 4950 tf_correct = logical 1 x2str = '24502500' len = 8 ans = logical 1

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

x = 5050 tf_correct = logical 1 x2str = '25502500' len = 8 ans = logical 1

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

x = 7272 tf_correct = logical 1 x2str = '52881984' len = 8 ans = logical 1

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

x = 7777 tf_correct = logical 1 x2str = '60481729' len = 8 ans = logical 1

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

x = 9999 tf_correct = logical 1 x2str = '99980001' len = 8 ans = logical 1

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

x = 17344 tf_correct = logical 1 x2str = '300814336' len = 9 ans = logical 1

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

x = 22222 tf_correct = logical 1 x2str = '493817284' len = 9 ans = logical 1

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

x = 77778 tf_correct = logical 1 x2str = '6049417284' len = 10 ans = logical 1

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

x = 82656 tf_correct = logical 1 x2str = '6832014336' len = 10 ans = logical 1

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

x = 95121 tf_correct = logical 1 x2str = '9048004641' len = 10 ans = logical 1

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

x = 99999 tf_correct = logical 1 x2str = '9999800001' len = 10 ans = logical 1

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

x = 142857 tf_correct = logical 1 x2str = '20408122449' len = 11 ans = logical 1

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

x = 148149 tf_correct = logical 1 x2str = '21948126201' len = 11 ans = logical 1

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

x = 181819 tf_correct = logical 1 x2str = '33058148761' len = 11 ans = logical 1

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

x = 187110 tf_correct = logical 1 x2str = '35010152100' len = 11 ans = logical 1

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

x = 208495 tf_correct = logical 1 x2str = '43470165025' len = 11 ans = logical 1

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

x = 318682 tf_correct = logical 1 x2str = '101558217124' len = 12 ans = logical 1

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

x = 329967 tf_correct = logical 1 x2str = '108878221089' len = 12 ans = logical 1

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

x = 351352 tf_correct = logical 1 x2str = '123448227904' len = 12 ans = logical 1

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

x = 356643 tf_correct = logical 1 x2str = '127194229449' len = 12 ans = logical 1

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

x = 390313 tf_correct = logical 1 x2str = '152344237969' len = 12 ans = logical 1

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

x = 461539 tf_correct = logical 1 x2str = '213018248521' len = 12 ans = logical 1

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

x = 466830 tf_correct = logical 1 x2str = '217930248900' len = 12 ans = logical 1

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

x = 499500 tf_correct = logical 1 x2str = '249500250000' len = 12 ans = logical 1

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

x = 500500 tf_correct = logical 1 x2str = '250500250000' len = 12 ans = logical 1

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

x = 533170 tf_correct = logical 1 x2str = '284270248900' len = 12 ans = logical 1

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

x = 538461 tf_correct = logical 1 x2str = '289940248521' len = 12 ans = logical 1

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

x = 609687 tf_correct = logical 1 x2str = '371718237969' len = 12 ans = logical 1

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

x = 643357 tf_correct = logical 1 x2str = '413908229449' len = 12 ans = logical 1

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

x = 648648 tf_correct = logical 1 x2str = '420744227904' len = 12 ans = logical 1

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

x = 670033 tf_correct = logical 1 x2str = '448944221089' len = 12 ans = logical 1

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

x = 681318 tf_correct = logical 1 x2str = '464194217124' len = 12 ans = logical 1

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

x = 681319 tf_correct = logical 0 x2str = '464195579761' len = 12 ans = logical 0

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

x = 681320 tf_correct = logical 0 x2str = '464196942400' len = 12 ans = logical 0

Community Treasure Hunt

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

Start Hunting!