-
Notifications
You must be signed in to change notification settings - Fork 0
/
year40-small.hrm
89 lines (73 loc) · 2.55 KB
/
year40-small.hrm
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- HUMAN RESOURCE MACHINE PROGRAM --
-- 40: Prime Factory
-- INSTRUCTIONS: "For each thing in the INBOX, send its PRIME FACTORS to
-- the OUTBOX in order from smallest to largest."
-- AVAILABLE COMMANDS: INBOX, OUTBOX, COPYFROM, COPYTO, ADD, SUB,
-- BUMPUP, BUMPDN, JUMP, JUMPZ, JUMPN, COMMENT
-- SIZE: 24 commands (challenge 28)
-- AVERAGE RUNTIME: 462 steps (challenge 399)
-- Tile 20: Current value being factorized
-- Tile 21: Working tile
-- Tile 22: Potential quotient after factoring out tile 23
-- Tile 23: Current prime factor candidate
-- Tile 24: Permanent zero
-- Starting with two, test an integer P for divisibility into the
-- value from the inbox, N. If P does divide evenly, place it in the
-- outbox and continue divisibility testing with the quotient N/P. If
-- P does not divide evenly, try again with P+1. Move on to the next
-- value from the inbox when P becomes larger than the dividend
-- currently being tested.
a:
COPYFROM 24
COPYTO 23
BUMPUP 23
BUMPUP 23
INBOX
JUMP c
b:
COPYFROM 23
OUTBOX
COPYFROM 22
c:
COPYTO 20
SUB 23
JUMPN a
JUMP e
d:
BUMPUP 23
e:
COPYFROM 24
COPYTO 22
COPYFROM 20
f:
SUB 23
COPYTO 21
JUMPN d
BUMPUP 22
COPYFROM 21
JUMPZ b
JUMP f
DEFINE LABEL 20
eJzjZwCCJB7PuqTStJYEpS0gbmXKhqRPafPD7ubxeAoW83h6lt0Kai3/nHK0XLDKs+zc0o6ymA2cZYmb
QWqXNqdu02zK3KndWHYoo+no2Yct/VeudUy+HtA9+fq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