-
Notifications
You must be signed in to change notification settings - Fork 1
/
day14_tests.tal
97 lines (83 loc) · 1.81 KB
/
day14_tests.tal
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
90
91
92
93
94
95
96
97
~library/macros.tal
~library/devices.tal
( variables )
|0000
|0100 @program
T< "parse-input: >T
S<
"NNCB 0a
0a
"CH 20 "-> 20 "B 0a
"ZH 20 "-> 20 "N 0a
>S ;test-parse-input JSR2
( EXPECT NNCB )
( EXPECT CH>B ZH>N )
T< "pair-counts: >T
S< "NNNCB 0a 0a >S ;make-get-byte JSR2 ;parse-input JSR2
;pair-counts/init JSR2
;pair-counts/dump JSR2 LF
( EXPECT NN:2 NC:1 CB:1 )
T< "apply-rules: >T
;day14sample ;make-get-byte JSR2 ;parse-input JSR2
;elt-counts/init JSR2
;pair-counts/init JSR2
;apply-rules JSR2
;pair-counts/dump JSR2 LF
( EXPECT NC:1 NB:1 CN:1 CH:1 BC:1 HB:1 )
#0000 #0009 DO
;apply-rules JSR2
LOOP
;pair-counts/dump JSR2 LF
( EXPECT NC:42 NB:796 NH:27 CN:102 CC:60 CB:115 CH:21 BN:735 BC:120 BB:812 BH:81 HN:27 HC:76 HB:26 HH:32 )
;elt-counts/dump JSR2 LF
( EXPECT N:865 C:298 B:1749 H:161 )
;elt-counts/print-result JSR2 LF
( EXPECT 1749-161=1588 )
#0000 #001e ( 30 more ) DO
;apply-rules JSR2
LOOP
;elt-counts/print-result JSR2 LF
( EXPECT 2192039569602-3849876073=2188189693529 )
T< "👍 >T
BRK !
~day14_lib.tal
@day14sample
"NNCB 0a
0a
"CH 20 "-> 20 "B 0a
"HH 20 "-> 20 "N 0a
"CB 20 "-> 20 "H 0a
"NH 20 "-> 20 "C 0a
"HB 20 "-> 20 "C 0a
"HC 20 "-> 20 "B 0a
"HN 20 "-> 20 "C 0a
"NN 20 "-> 20 "C 0a
"BH 20 "-> 20 "H 0a
"NC 20 "-> 20 "B 0a
"NB 20 "-> 20 "B 0a
"BN 20 "-> 20 "B 0a
"BB 20 "-> 20 "N 0a
"BC 20 "-> 20 "B 0a
"CC 20 "-> 20 "N 0a
"CN 20 "-> 20 "C 0a
00
|f000
~library/test.tal
( s* -- )
@test-parse-input
;make-get-byte JSR2 ;parse-input JSR2
;dump-polymer JSR2 LF
;dump-rules JSR2 LF
RTN
( s* -- get-byte )
@make-get-byte
;input STA2
;get-byte-from-input
RTN
( -- b )
@get-byte-from-input
[ ;input LDA2 ] LDA STH
[ ;input LDA2 ] INC2 [ ;input STA2 ]
STHr
RTN
@input $2