-
Notifications
You must be signed in to change notification settings - Fork 0
/
year19-fast.hrm
63 lines (52 loc) · 997 Bytes
/
year19-fast.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
-- HUMAN RESOURCE MACHINE PROGRAM --
-- 19: Countdown
-- INSTRUCTIONS: "For each number in the INBOX, send that number to the
-- OUTBOX, followed by all numbers down to (or up to) zero. It's
-- a countdown!"
-- AVAILABLE COMMANDS: INBOX, OUTBOX, COPYFROM, COPYTO, ADD, SUB,
-- BUMPUP, BUMPDN, JUMP, JUMPZ, JUMPN, COMMENT
-- SIZE: 30 commands (challenge 10)
-- AVERAGE RUNTIME: 70 steps (challenge 82)
-- The first item is always greater than 1.
INBOX
COPYTO 0
OUTBOX
BUMPDN 0
a:
OUTBOX
BUMPDN 0
JUMPZ b
JUMP a
b:
OUTBOX
-- The second item is always less than -1.
INBOX
COPYTO 0
OUTBOX
BUMPUP 0
c:
OUTBOX
d:
BUMPUP 0
JUMPZ e
JUMP c
e:
OUTBOX
-- The third item is always 0.
INBOX
f:
g:
OUTBOX
-- The last item varies.
INBOX
JUMPZ g
COPYTO 0
OUTBOX
COPYFROM 0
JUMPN d
h:
BUMPDN 0
JUMPZ f
OUTBOX
JUMP h
-- vim: set autoindent: