Test  Status  Code Input and Output 

1  Pass 
x = 0;
y_correct = 0;
assert(isequal(ones_ratio(x),y_correct))
r =
0

2  Pass 
x = 1;
y_correct = 1;
assert(isequal(ones_ratio(x),y_correct))
r =
1

3  Pass 
x = 2;
y_correct = 0.5;
assert(isequal(ones_ratio(x),y_correct))
bit =
2
n1 =
1
n =
0
n0 =
1
r =
0.5000

4  Pass 
x = 7;
y_correct = 1;
assert(isequal(ones_ratio(x),y_correct))
bit =
3
n1 =
1
n =
3
n1 =
2
n =
1
n1 =
3
n =
0
r =
1

5  Pass 
x = 128;
y_correct = 0.125;
assert(isequal(ones_ratio(x),y_correct))
bit =
8
n1 =
1
n =
0
n0 =
1
n0 =
2
n0 =
3
n0 =
4
n0 =
5
n0 =
6
n0 =
7
r =
0.1250

6  Pass 
x = 1265476542;
y_correct = 19/31;
assert(isequal(ones_ratio(x),y_correct))
bit =
31
n1 =
1
n =
191734718
n0 =
1
n0 =
2
n1 =
2
n =
57516990
n0 =
3
n1 =
3
n =
23962558
n1 =
4
n =
7185342
n0 =
4
n1 =
5
n =
2991038
n1 =
6
n =
893886
n0 =
5
n1 =
7
n =
369598
n1 =
8
n =
107454
n0 =
6
n1 =
9
n =
41918
n1 =
10
n =
9150
n0 =
7
n1 =
11
n =
958
n0 =
8
n0 =
9
n0 =
10
n1 =
12
n =
446
n1 =
13
n =
190
n1 =
14
n =
62
n0 =
11
n1 =
15
n =
30
n1 =
16
n =
14
n1 =
17
n =
6
n1 =
18
n =
2
n1 =
19
n =
0
n0 =
12
r =
0.6129

7  Pass 
x = 98917653181;
y_correct = 23/37;
assert(isequal(ones_ratio(x),y_correct))
bit =
37
n1 =
1
n =
3.0198e+10
n0 =
1
n1 =
2
n =
1.3018e+10
n1 =
3
n =
4.4284e+09
n1 =
4
n =
133405373
n0 =
2
n0 =
3
n0 =
4
n0 =
5
n0 =
6
n1 =
5
n =
66296509
n1 =
6
n =
32742077
n1 =
7
n =
15964861
n1 =
8
n =
7576253
n1 =
9
n =
3381949
n1 =
10
n =
1284797
n1 =
11
n =
236221
n0 =
7
n0 =
8
n1 =
12
n =
105149
n1 =
13
n =
39613
n1 =
14
n =
6845
n0 =
9
n0 =
10
n1 =
15
n =
2749
n1 =
16
n =
701
n0 =
11
n1 =
17
n =
189
n0 =
12
n1 =
18
n =
61
n0 =
13
n1 =
19
n =
29
n1 =
20
n =
13
n1 =
21
n =
5
n1 =
22
n =
1
n0 =
14
n1 =
23
n =
0
r =
0.6216

Rotate and display numbered tile
221 Solvers
Make a random, nonrepeating vector.
1058 Solvers
Getting the absolute index from a matrix
176 Solvers
196 Solvers
1477 Solvers