Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 66738

Submitted on 28 Mar 2012

Incorrect

67Size
Leading solution size is 31.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 

                      

                    
2
Pass
 
%%
x = 704;
tf_correct = false;
assert(isequal(kap(x),tf_correct))
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     0
3
Pass
 
%%
x = 9
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
     9
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
4
Pass
 
%%
x = 45
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
    45
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
5
Pass
 
%%
x = 55
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
    55
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
6
Pass
 
%%
x = 99
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
    99
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
7
Pass
 
%%
x = 297
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
   297
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
8
Pass
 
%%
x = 703
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
   703
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
9
Pass
 
%%
x = 999
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
   999
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
10
Pass
 
%%
x = 2223
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        2223
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
11
Pass
 
%%
x = 2728
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        2728
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
12
Pass
 
%%
x = 4950
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        4950
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
13
Pass
 
%%
x = 5050
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        5050
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
14
Pass
 
%%
x = 7272
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        7272
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
15
Pass
 
%%
x = 7777
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        7777
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
16
Pass
 
%%
x = 9999
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
        9999
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
17
Pass
 
%%
x = 17344
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
       17344
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
18
Pass
 
%%
x = 22222
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
       22222
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
19
Pass
 
%%
x = 77778
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
       77778
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
20
Pass
 
%%
x = 82656
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
       82656
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
21
Pass
 
%%
x = 95121
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
       95121
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
22
Pass
 
%%
x = 99999
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
       99999
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
23
Pass
 
%%
x = 142857
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      142857
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
24
Pass
 
%%
x = 148149
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      148149
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
25
Pass
 
%%
x = 181819
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      181819
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
26
Pass
 
%%
x = 187110
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      187110
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
27
Pass
 
%%
x = 208495
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      208495
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
28
Pass
 
%%
x = 318682
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      318682
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
29
Pass
 
%%
x = 329967
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      329967
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
30
Pass
 
%%
x = 351352
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      351352
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
31
Pass
 
%%
x = 356643
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      356643
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
32
Pass
 
%%
x = 390313
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      390313
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
33
Pass
 
%%
x = 461539
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      461539
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
34
Pass
 
%%
x = 466830
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      466830
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
35
Pass
 
%%
x = 499500
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      499500
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
36
Pass
 
%%
x = 500500
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      500500
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
37
Pass
 
%%
x = 533170
tf_correct = true
assert(isequal(kap(x),tf_correct))
x =
      533170
tf_correct =
     1
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     1
38
Fail
 
%%
x = 538461
tf_correct = true
assert(isequal(kap(x),tf_correct))
Error: Assertion failed.
39
Fail
 
%%
x = 609687
tf_correct = true
assert(isequal(kap(x),tf_correct))
Error: Assertion failed.
40
Fail
 
%%
x = 643357
tf_correct = true
assert(isequal(kap(x),tf_correct))
Error: Assertion failed.
41
Fail
 
%%
x = 648648
tf_correct = true
assert(isequal(kap(x),tf_correct))
Error: Assertion failed.
42
Fail
 
%%
x = 670033
tf_correct = true
assert(isequal(kap(x),tf_correct))
Error: Assertion failed.
43
Fail
 
%%
x = 681318
tf_correct = true
assert(isequal(kap(x),tf_correct))
Error: Assertion failed.
44
Pass
 
%%
x = 681319
tf_correct = false
assert(isequal(kap(x),tf_correct))
x =
      681319
tf_correct =
     0
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     0
45
Pass
 
%%
x = 681320
tf_correct = false
assert(isequal(kap(x),tf_correct))
x =
      681320
tf_correct =
     0
kaprekar =
  Columns 1 through 8
           1           9          45          55          99         297         703         999
  Columns 9 through 16
        2223        2728        4879        4950        5050        5292        7272        7777
  Columns 17 through 24
        9999       17344       22222       38962       77778       82656       95121       99999
  Columns 25 through 32
      142857      148149      181819      187110      208495      318682      329967      351352
  Columns 33 through 39
      356643      390313      461539      466830      499500      500500      533170
tf =
     0