From 639310feda93107a7c321137e4c65414c3895728 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 1 Dec 2025 12:19:01 -0500 Subject: [PATCH] 2025.01.1 --- aoc/2025/01.input.test | 10 ++++ aoc/2025/01.tal | 113 +++++++++++++++++++++++++++++++++++++---- aoc/2025/mkfile | 3 +- aoc/2025/xx.tal | 44 ++++++++++++++-- 4 files changed, 157 insertions(+), 13 deletions(-) create mode 100644 aoc/2025/01.input.test diff --git a/aoc/2025/01.input.test b/aoc/2025/01.input.test new file mode 100644 index 0000000000000000000000000000000000000000..53287c7b25e4636b459eaa50a4e514f7405c07ec --- /dev/null +++ b/aoc/2025/01.input.test @@ -0,0 +1,10 @@ +L68 +L30 +R48 +L5 +R60 +L55 +L1 +L99 +R14 +L82 diff --git a/aoc/2025/01.tal b/aoc/2025/01.tal index 21e484cfec9aa27197774e5d96e61b0ea4a758ba..9f8d9a7129a0ace28b2e3431a82a85d26809a6f4 100644 --- a/aoc/2025/01.tal +++ b/aoc/2025/01.tal @@ -1,22 +1,117 @@ ( advent of code 2025, day 1 ) +%dbg { #010e DEO } + +|00 + +|100 @on-reset ( -> ) - ;on-input #10 DEO2 banner + first-star BRK @banner ( -- ) - ;/str - &loop - LDAk #18 DEO - INC2 LDAk ?/loop - POP2 JMP2r + ;/str !puts @banner/str "advent 20 "of 20 "code, 20 "day 20 "1 0a 00 -@on-input ( -> ) - #12 DEI + +( first star ) + +@first-star ( -- ) + ;/input Input/read + + [ LIT2 &pass $2 ] + ;/str puts + putdec2 endl + + JMP2r +@first-star/str "first 20 "star: 20 00 + +@first-star/newline ( -- ) + Number/get Dial/rotate + Number/reset + + Dial/get ORA ?{ ,/pass LDR2 INC2 ,/pass STR2 } + JMP2r + +@first-star/input ( b -- ) + DUP #0a NEQ ?{ POP !/newline } + DUP LIT "R NEQ ?{ POP !Dial/right } + DUP LIT "L NEQ ?{ POP !Dial/left } + !Number/one-byte + + +( stdlib ) + +@endl ( n -- ) + #0a18 DEO JMP2r + +@puts ( str* -- ) + LDAk #18 DEO + INC2 LDAk ?puts + + POP2 JMP2r + +@putdec2 ( n* -- ) + [ LITr 00 ] + + &loop + #000a DIV2k STH2k + MUL2 SUB2 + [ LIT "0 ] ADD NIP + STH2r ROT STH + ORAk ?/loop + POP2 + &loop2 + STHr #18 DEO + STHrk ?/loop2 + POPr JMP2r + + +( object lib ) + +@Input/filename "01.input 00 +@Input/read ( callback* -- ) + ;/filename #a8 DEO2 + #01ab DEO - BRK + &loop + DUP2 + ;/byte #ac DEO2 + #a3 DEI #00 EQU ?/endloop ( EOF ) + [ LIT &byte $1 ] + ROT ROT JSR2 + !/loop + + &endloop + POP2 JMP2r + +@Number/one-byte ( b -- ) + #00 SWP + LIT "0 SUB + [ LIT2 &val 0000 ] + #000a MUL2 ADD2 + ,/val STR2 + JMP2r +@Number/get ( -- n* ) + ,/val LDR2 JMP2r +@Number/reset ( -- ) + #0000 ,/val STR2 JMP2r + +( problem code ) + +@Dial/get ( -- n* ) + ,/state LDR2 #6400 SUB2 JMP2r +@Dial/rotate ( n* -- ) + [ LIT2 &state 6432 ] ( start @ 1050 ) + SWP2 &op $1 + #0064 DIV2k MUL2 SUB2 ( mod 100 ) + #6400 ADD2 ( keep in range 100-199 ) + ,/state STR2 +@Dial/left ( -- ) + [ LIT2 SUB2 _/op ] STR JMP2r +@Dial/right ( -- ) + [ LIT2 ADD2 _/op ] STR JMP2r diff --git a/aoc/2025/mkfile b/aoc/2025/mkfile index a4f09272c3097f273353a0426b87079825e3e26d..68c808fdd0388177d178215d6e41c64d5e8934c0 100644 --- a/aoc/2025/mkfile +++ b/aoc/2025/mkfile @@ -3,8 +3,9 @@ DAYS=01.rom all:VQ: $DAYS %:V: %.rom - uxncli $stem.rom <$stem.input + uxncli $stem.rom %.rom: %.tal drifblim $stem.tal $stem.rom + diff --git a/aoc/2025/xx.tal b/aoc/2025/xx.tal index 21e484cfec9aa27197774e5d96e61b0ea4a758ba..28bdf484d59511c4bca437ee81b3b8836c01acd2 100644 --- a/aoc/2025/xx.tal +++ b/aoc/2025/xx.tal @@ -1,7 +1,11 @@ -( advent of code 2025, day 1 ) +( advent of code 2025, day xx ) +%dbg { #100e DEO } + +|00 + +|100 @on-reset ( -> ) - ;on-input #10 DEO2 banner BRK @@ -12,11 +16,45 @@ INC2 LDAk ?/loop POP2 JMP2r @banner/str - "advent 20 "of 20 "code, 20 "day 20 "1 0a 00 + "advent 20 "of 20 "code, 20 "day 20 "xx 0a 00 + + +@Input/filename "xx.input 00 +@Input/read ( callback* -- ) + ;/filename #a8 DEO2 + #01ab DEO2 + + &loop + DUP2 + ;/byte #ac DEO2 + #a3 DEI #00 EQU ?/endloop ( EOF ) + [ LIT &byte $1 ] + ROT ROT JSR2 + !/loop + &endloop + POP2 JMP2r + + +@first-star ( -- ) @on-input ( -> ) #12 DEI BRK + +@Number/one-byte ( b -- ) + #00 SWP + LIT "0 SUB + [ LIT2 &val 00 &val2 00 ] + #000a MUL2 ADD2 + ,/val STR2 + JMP2r +@Number/get2 ( -- n* ) + ,/val LDR2 JMP2r +@Number/get1 ( -- n ) + ,/val2 LDR JMP2r +@Number/reset ( -- ) + #0000 ,/val STR2 JMP2r +