-
Notifications
You must be signed in to change notification settings - Fork 0
/
year22.hrm
79 lines (62 loc) · 2.49 KB
/
year22.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
-- HUMAN RESOURCE MACHINE PROGRAM --
-- 22: Fibonacci Visitor
-- INSTRUCTIONS: "For each thing in the INBOX, send to the OUTBOX the
-- full Fibonacci Sequence up to, but not exceeding that value. For
-- example, if INBOX is 10, OUTBOX should be 1 1 2 3 5 8. What's
-- a Fibonacci Sequence? Ask your boss, or a friendly search box."
-- AVAILABLE COMMANDS: INBOX, OUTBOX, COPYFROM, COPYTO, ADD, SUB,
-- BUMPUP, BUMPDN, JUMP, JUMPZ, JUMPN, COMMENT
-- SIZE: 17 commands (challenge 19)
-- AVERAGE RUNTIME: 131 steps (challenge 156)
-- I have not attempted to unroll this program.
-- Tile 0: Current Fibonacci number
-- Tile 1: "Future" Fibonacci number (to be used on next iteration)
-- Tile 2: Upper bound, taken from the inbox
-- Tile 9: Permanent zero
a:
-- Save the target value from the inbox, then initialize the working
-- tiles to 1.
INBOX
COPYTO 2
COPYFROM 9
COPYTO 0
BUMPUP 0
COPYTO 1
b:
c:
COPYFROM 0
OUTBOX
-- Generate the next Fibonacci number on tile 1 and place the current one
-- on tile 0.
COPYFROM 0
ADD 1
COPYTO 1
SUB 0
COPYTO 0
-- If the current number doesn't exceed the upper bound, send it to the
-- outbox. If it does, grab the next bound from the inbox and start over.
SUB 2
JUMPN c
JUMPZ b
JUMP a
DEFINE LABEL 0
eJwTZWBgKPd9pLXdN/EhkMmw3Xd+y7qM+S0gtqnfZHnOshAFEPtqYeH+q4VqT8MKP78D8flL7E8eL9ty
0LnC6EBt1YZ9X2oL9+s1NJ1+X1/4FiTf3x1w1WpywFUQO3K+6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