Test  Status  Code Input and Output 

1  Pass 
x = 3276;
y_correct = 5;
assert(isequal(KaprekarSteps(x),y_correct))
y =
3276
c =
0
y =
'3276'
a =
'2367'
d =
'7632'
y =
5265
c =
1
y =
'5265'
a =
'2556'
d =
'6552'
y =
3996
c =
2
y =
'3996'
a =
'3699'
d =
'9963'
y =
6264
c =
3
y =
'6264'
a =
'2466'
d =
'6642'
y =
4176
c =
4
y =
'4176'
a =
'1467'
d =
'7641'
y =
6174
c =
5
y =
5

2  Pass 
x = 3;
y_correct = 6;
assert(isequal(KaprekarSteps(x),y_correct))
y =
3
c =
0
y =
'3'
a =
'0003'
d =
'3000'
y =
2997
c =
1
y =
'2997'
a =
'2799'
d =
'9972'
y =
7173
c =
2
y =
'7173'
a =
'1377'
d =
'7731'
y =
6354
c =
3
y =
'6354'
a =
'3456'
d =
'6543'
y =
3087
c =
4
y =
'3087'
a =
'0378'
d =
'8730'
y =
8352
c =
5
y =
'8352'
a =
'2358'
d =
'8532'
y =
6174
c =
6
y =
6

3  Pass 
x = 691;
y_correct = 7;
assert(isequal(KaprekarSteps(x),y_correct))
y =
691
c =
0
y =
'691'
a =
'0169'
d =
'9610'
y =
9441
c =
1
y =
'9441'
a =
'1449'
d =
'9441'
y =
7992
c =
2
y =
'7992'
a =
'2799'
d =
'9972'
y =
7173
c =
3
y =
'7173'
a =
'1377'
d =
'7731'
y =
6354
c =
4
y =
'6354'
a =
'3456'
d =
'6543'
y =
3087
c =
5
y =
'3087'
a =
'0378'
d =
'8730'
y =
8352
c =
6
y =
'8352'
a =
'2358'
d =
'8532'
y =
6174
c =
7
y =
7

4  Pass 
x = 3333;
y_correct = Inf;
assert(isequal(KaprekarSteps(x),y_correct))
y =
3333
c =
0
y =
'3333'
a =
'3333'
d =
'3333'
y =
0
c =
1
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
2
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
3
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
4
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
5
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
6
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
7
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
8
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
9
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
10
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
11
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
12
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
13
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
14
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
15
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
16
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
17
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
18
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
19
y =
'0'
a =
'0000'
d =
'0000'
y =
0
c =
20
y =
20
y =
Inf

5  Pass 
x = 1;
y_correct = 5;
assert(isequal(KaprekarSteps(x),y_correct))
y =
1
c =
0
y =
'1'
a =
'0001'
d =
'1000'
y =
999
c =
1
y =
'999'
a =
'0999'
d =
'9990'
y =
8991
c =
2
y =
'8991'
a =
'1899'
d =
'9981'
y =
8082
c =
3
y =
'8082'
a =
'0288'
d =
'8820'
y =
8532
c =
4
y =
'8532'
a =
'2358'
d =
'8532'
y =
6174
c =
5
y =
5

6  Pass 
x = 6174;
y_correct = 0;
assert(isequal(KaprekarSteps(x),y_correct))
y =
6174
c =
0
y =
0

7  Pass 
x = 1234;
y_correct = 3;
assert(isequal(KaprekarSteps(x),y_correct))
y =
1234
c =
0
y =
'1234'
a =
'1234'
d =
'4321'
y =
3087
c =
1
y =
'3087'
a =
'0378'
d =
'8730'
y =
8352
c =
2
y =
'8352'
a =
'2358'
d =
'8532'
y =
6174
c =
3
y =
3

8  Pass 
x = 3141;
y_correct = 5;
assert(isequal(KaprekarSteps(x),y_correct))
y =
3141
c =
0
y =
'3141'
a =
'1134'
d =
'4311'
y =
3177
c =
1
y =
'3177'
a =
'1377'
d =
'7731'
y =
6354
c =
2
y =
'6354'
a =
'3456'
d =
'6543'
y =
3087
c =
3
y =
'3087'
a =
'0378'
d =
'8730'
y =
8352
c =
4
y =
'8352'
a =
'2358'
d =
'8532'
y =
6174
c =
5
y =
5

9  Pass 
x = 8080;
y_correct = 6;
assert(isequal(KaprekarSteps(x),y_correct))
y =
8080
c =
0
y =
'8080'
a =
'0088'
d =
'8800'
y =
8712
c =
1
y =
'8712'
a =
'1278'
d =
'8721'
y =
7443
c =
2
y =
'7443'
a =
'3447'
d =
'7443'
y =
3996
c =
3
y =
'3996'
a =
'3699'
d =
'9963'
y =
6264
c =
4
y =
'6264'
a =
'2466'
d =
'6642'
y =
4176
c =
5
y =
'4176'
a =
'1467'
d =
'7641'
y =
6174
c =
6
y =
6

Swap the first and last columns
9904 Solvers
Back to basics 19  character types
189 Solvers
Basics: 'Find the eigenvalues of given matrix
257 Solvers
Is this triangle rightangled?
1921 Solvers
A Simple Tide Gauge with MATLAB
300 Solvers