-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotes.txt
50 lines (41 loc) · 1.06 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
The program looks like this:
bst 4: 2411751540550330 - 64854237,0,0
bxl 1: 2411751540550330 - 64854237,5,0
cdv 5: 2411751540550330 - 64854237,4,0
bxl 5: 2411751540550330 - 64854237,4,4053389
bxc 0: 2411751540550330 - 64854237,1,4053389
out 5: 2411751540550330 - 64854237,4053388,4053389
adv 3: 2411751540550330 - 64854237,4053388,4053389
jnz 0: 2411751540550330 - 8106779,4053388,4053389
(repeat from top...)
In pseudocode:
do {
B = A & 0b111;
B ^= 1 (= 0b001);
C = A / (1 << B);
B ^= 5 (= 0b101);
B ^= C;
output(B & 0b111);
A /= (1 << 3);
} while (A > 0);
We can simplify this to:
do {
B = (A & 0b111) ^ 0b001;
C = A >> B;
B ^= C ^ 0b101;
output(B & 0b111);
A >>= 3;
} while (A > 0);
Simplified even further:
do {
B = (A & 0b111) ^ 0b001;
B ^= (A >> B) ^ 0b101;
output(B & 0b111);
A >>= 3;
} while (A > 0);
And even further, using a new constant `L` for better readability:
do {
L = A & 0b111;
output((L ^ 0b100 ^ (A >> (L ^ 0b001))) & 0b111);
A >>= 3;
} while (A > 0);