Cody

# Problem 166. Kaprekar numbers

Solution 1123636

Submitted on 15 Feb 2017 by mohammad z
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))

u = 2 5 6 m = 1 vs = 58

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

u = 4 9 5 6 1 6 m = 3 vs = 1111

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

x = 9 tf_correct = logical 1 u = 8 1 m = 1 vs = 9 tf = 1

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

x = 45 tf_correct = logical 1 u = 2 0 2 5 m = 2 vs = 45 tf = 1

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

x = 55 tf_correct = logical 1 u = 3 0 2 5 m = 2 vs = 55 tf = 1

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

x = 99 tf_correct = logical 1 u = 9 8 0 1 m = 2 vs = 99 tf = 1

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

x = 297 tf_correct = logical 1 u = 8 8 2 0 9 m = 2 vs = 297 tf = 1

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

x = 703 tf_correct = logical 1 u = 4 9 4 2 0 9 m = 3 vs = 703 tf = 1

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

x = 999 tf_correct = logical 1 u = 9 9 8 0 0 1 m = 3 vs = 999 tf = 1

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

x = 2223 tf_correct = logical 1 u = 4 9 4 1 7 2 9 m = 3 vs = 2223 tf = 1

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

x = 2728 tf_correct = logical 1 u = 7 4 4 1 9 8 4 m = 3 vs = 2728 tf = 1

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

x = 4950 tf_correct = logical 1 u = 2 4 5 0 2 5 0 0 m = 4 vs = 4950 tf = 1

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

x = 5050 tf_correct = logical 1 u = 2 5 5 0 2 5 0 0 m = 4 vs = 5050 tf = 1

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

x = 7272 tf_correct = logical 1 u = 5 2 8 8 1 9 8 4 m = 4 vs = 7272 tf = 1

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

x = 7777 tf_correct = logical 1 u = 6 0 4 8 1 7 2 9 m = 4 vs = 7777 tf = 1

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

x = 9999 tf_correct = logical 1 u = 9 9 9 8 0 0 0 1 m = 4 vs = 9999 tf = 1

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

x = 17344 tf_correct = logical 1 u = 3 0 0 8 1 4 3 3 6 m = 4 vs = 17344 tf = 1

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

x = 22222 tf_correct = logical 1 u = 4 9 3 8 1 7 2 8 4 m = 4 vs = 22222 tf = 1

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

x = 77778 tf_correct = logical 1 u = 6 0 4 9 4 1 7 2 8 4 m = 5 vs = 77778 tf = 1

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

x = 82656 tf_correct = logical 1 u = 6 8 3 2 0 1 4 3 3 6 m = 5 vs = 82656 tf = 1

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

x = 95121 tf_correct = logical 1 u = 9 0 4 8 0 0 4 6 4 1 m = 5 vs = 95121 tf = 1

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

x = 99999 tf_correct = logical 1 u = 9 9 9 9 8 0 0 0 0 1 m = 5 vs = 99999 tf = 1

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

x = 142857 tf_correct = logical 1 u = 2 0 4 0 8 1 2 2 4 4 9 m = 5 vs = 142857 tf = 1

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

x = 148149 tf_correct = logical 1 u = 2 1 9 4 8 1 2 6 2 0 1 m = 5 vs = 148149 tf = 1

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

x = 181819 tf_correct = logical 1 u = 3 3 0 5 8 1 4 8 7 6 1 m = 5 vs = 181819 tf = 1

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

x = 187110 tf_correct = logical 1 u = 3 5 0 1 0 1 5 2 1 0 0 m = 5 vs = 187110 tf = 1

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

x = 208495 tf_correct = logical 1 u = 4 3 4 7 0 1 6 5 0 2 5 m = 5 vs = 208495 tf = 1

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

x = 318682 tf_correct = logical 1 u = 1 0 1 5 5 8 2 1 7 1 2 4 m = 6 vs = 318682 tf = 1

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

x = 329967 tf_correct = logical 1 u = 1 0 8 8 7 8 2 2 1 0 8 9 m = 6 vs = 329967 tf = 1

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

x = 351352 tf_correct = logical 1 u = 1 2 3 4 4 8 2 2 7 9 0 4 m = 6 vs = 351352 tf = 1

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

x = 356643 tf_correct = logical 1 u = 1 2 7 1 9 4 2 2 9 4 4 9 m = 6 vs = 356643 tf = 1

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

x = 390313 tf_correct = logical 1 u = 1 5 2 3 4 4 2 3 7 9 6 9 m = 6 vs = 390313 tf = 1

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

x = 461539 tf_correct = logical 1 u = 2 1 3 0 1 8 2 4 8 5 2 1 m = 6 vs = 461539 tf = 1

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

x = 466830 tf_correct = logical 1 u = 2 1 7 9 3 0 2 4 8 9 0 0 m = 6 vs = 466830 tf = 1

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

x = 499500 tf_correct = logical 1 u = 2 4 9 5 0 0 2 5 0 0 0 0 m = 6 vs = 499500 tf = 1

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

x = 500500 tf_correct = logical 1 u = 2 5 0 5 0 0 2 5 0 0 0 0 m = 6 vs = 500500 tf = 1

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

x = 533170 tf_correct = logical 1 u = 2 8 4 2 7 0 2 4 8 9 0 0 m = 6 vs = 533170 tf = 1

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

x = 538461 tf_correct = logical 1 u = 2 8 9 9 4 0 2 4 8 5 2 1 m = 6 vs = 538461 tf = 1

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

x = 609687 tf_correct = logical 1 u = 3 7 1 7 1 8 2 3 7 9 6 9 m = 6 vs = 609687 tf = 1

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

x = 643357 tf_correct = logical 1 u = 4 1 3 9 0 8 2 2 9 4 4 9 m = 6 vs = 643357 tf = 1

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

x = 648648 tf_correct = logical 1 u = 4 2 0 7 4 4 2 2 7 9 0 4 m = 6 vs = 648648 tf = 1

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

x = 670033 tf_correct = logical 1 u = 4 4 8 9 4 4 2 2 1 0 8 9 m = 6 vs = 670033 tf = 1

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

x = 681318 tf_correct = logical 1 u = 4 6 4 1 9 4 2 1 7 1 2 4 m = 6 vs = 681318 tf = 1

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

x = 681319 tf_correct = logical 0 u = 4 6 4 1 9 5 5 7 9 7 6 1 m = 6 vs = 1043956

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

x = 681320 tf_correct = logical 0 u = 4 6 4 1 9 6 9 4 2 4 0 0 m = 6 vs = 1406596

### Community Treasure Hunt

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

Start Hunting!