aboutsummaryrefslogtreecommitdiff
path: root/Puzzle23translation.md
blob: 018e129ee35270e4107aaec0db9269aabeb60f5a (plain) (blame)
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
51
Translation from the assembly code to pseudocode:

'''
b = 105700
c = 122700

for b = 105700, 105717, .., 122683
    f = 1
    for d = 2 .. b
        for e = 2 .. b
            if d * e == b then f = 0
    if f == 0 then h += 1
return h
'''

The original assembly code:

'''
set b 57
set c b
jnz a 2
jnz 1 5
mul b 100
sub b -100000
set c b
sub c -17000
set f 1
set d 2
set e 2
set g d
mul g e
sub g b
jnz g 2
set f 0
sub e -1
set g e
sub g b
jnz g -8
sub d -1
set g d
sub g b
jnz g -13
jnz f 2
sub h -1
set g b
sub g c
jnz g 2
jnz 1 3
sub b -17
jnz 1 -23
'''