Skip to content

Commit

Permalink
day14b
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanperret committed Dec 14, 2021
1 parent bf49b8f commit 4643243
Show file tree
Hide file tree
Showing 13 changed files with 928 additions and 15 deletions.
9 changes: 0 additions & 9 deletions day10_lib.tal
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,6 @@
RTN
[ &min-ptr $2 &intmax ff ff ff ff ff ff ff 7f &min-out $8 ]

( a* b* -- f )
@greaterthan64
( OVR2 ;print64 JSR2 LIT '> EMIT DUP2 ;print64 JSR2 LIT '? EMIT SP )
STH2 STH2 ;&a-b STH2r STH2r ;sub64 JSR2
;&a-b ;is-positive64 JSR2
( DBGBYTE )
RTN
[ &a-b $8 ]


~library/console.lib.tal
~library/string.tal
Expand Down
3 changes: 0 additions & 3 deletions day12_tests.tal
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

|0000

%T< { STKCHK P< }
%>T { >P LF }

|0100 @program

T< "parse-line: >T
Expand Down
3 changes: 0 additions & 3 deletions day13_tests.tal
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

|0000

%T< { STKCHK P< }
%>T { >P LF }

|0100 @program

T< "parse-dot-line: >T
Expand Down
65 changes: 65 additions & 0 deletions day14.tal
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
~library/macros.tal
~library/devices.tal

( variables )

|0000

( init )

|0100 @program
;on-arg-char .Console/vector DEO2
BRK !

@on-arg-char
.Console/read DEI ( char )
DUP #0a EQU ,&complete JCN
;argv #00 ,&argptr LDR ADD2 STA
,&argptr LDR INC ,&argptr STR
BRK !

&complete
POP

;arg-received JMP2

&argptr $1

@argv $20

( arg is in @argv )
@arg-received
LIT ': EMIT
;argv ;print JSR2
LF

;open-file JSR2

;read-byte ;parse-input JSR2

;elt-counts/init JSR2
;pair-counts/init JSR2

#0001 #0029 DO
DUP2 DBGSHORTDECn LIT ': EMIT
;apply-rules JSR2
;elt-counts/print-result JSR2 LF
LOOP

BRK

[ ]

@open-file
;argv .File/name DEO2
#0001 .File/length DEO2
RTN

( -- next-byte )
@read-byte
#00 ;&byte STA ( clear byte so that EOF reads as zero )
;&byte .File/read DEO2
LIT &byte 00 ( <- this byte is patched by the two previous instructions! )
RTN

~day14_lib.tal
102 changes: 102 additions & 0 deletions day14.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
CVKKFSSNNHNPSPPKBHPB

OF -> S
VO -> F
BP -> S
FC -> S
PN -> K
HC -> P
PP -> N
FK -> V
KN -> C
BO -> O
KS -> B
FF -> S
KC -> B
FV -> C
VF -> N
HS -> H
OS -> F
VC -> S
VP -> P
BC -> O
HF -> F
HO -> F
PC -> B
CC -> K
NB -> N
KK -> N
KP -> V
BH -> H
BF -> O
OB -> F
VK -> P
FB -> O
NP -> B
CB -> C
PS -> S
KO -> V
SP -> C
BK -> O
NN -> O
OC -> F
VB -> B
ON -> K
NK -> B
CK -> H
NH -> N
CV -> C
PF -> P
PV -> V
CP -> N
FP -> N
SB -> B
SN -> N
KF -> F
HP -> S
BN -> V
NF -> B
PO -> O
CH -> O
VV -> S
OV -> V
SF -> P
BV -> S
FH -> V
CN -> H
VH -> V
HB -> B
FN -> P
OH -> S
SK -> H
OP -> H
VN -> V
HN -> P
BS -> S
CF -> B
PB -> H
SS -> K
NV -> P
FS -> N
CS -> O
OK -> B
CO -> O
VS -> F
OO -> B
NO -> H
SO -> F
HH -> K
FO -> H
SH -> O
HV -> B
SV -> N
PH -> F
BB -> P
KV -> B
KB -> H
KH -> N
NC -> P
SC -> S
PK -> B
NS -> V
HK -> B
Loading

0 comments on commit 4643243

Please sign in to comment.