advent-of-code-2025

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.alexwennerberg.com/advent-of-code-2025.git
Log | Files | Refs | README | LICENSE

commit 5da7c6b4a1b334aaae6a7820c4440542babe3ec3
parent 56e4038c96bfb0f453f37b5fad5581ed7d59e5c9
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  2 Jan 2026 23:12:15 -0800

solve day 1

Diffstat:
M.gitignore | 2++
M01.f | 23+++++++++--------------
2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,2 +1,4 @@ input sample +*.swp +uf.rom diff --git a/01.f b/01.f @@ -1,6 +1,4 @@ -\ 5866 too low - -\ utilities +\ util 4545 constant input-size : tibs ( -- a u ) tib >limit @ tib - ; : s>n ( a u -- n ) 0 -rot 0 do dup r@ + c@ h# 30 - rot 10 * + swap loop drop ; @@ -9,15 +7,12 @@ variable password variable passwordB \ for short : rotation ( a u -- n ) over c@ [char] O - 3 / -rot 1 /string s>n * ; -: wrap100+ ( n1 n2 -- n ) + dup 0 < if 100 mod 100 swap - then 100 mod ; -: count-crosses ( n1 n2 -- ) 2dup over 0= if drop drop exit then + 100 /mod abs swap 0< + .s cr passwordB +! ; -: solve ( -- ) 50 - input-size 0 do - query tibs rotation count-crosses wrap100+ - dup 0= if 1 password +! then - loop - password @ . cr - password @ - passwordB @ + .s cr - bye ; +: floor100 ( n -- n ) 100 /mod swap 0< if 1- then ; +: wrap100 ( n -- n ) dup floor100 100 * - ; +: rotate ( n -- n ) dup query tibs rotation >r r@ + ( old new ) + 2dup r> 0< if 1- swap 1- then \ inclusive / exclusive + floor100 swap floor100 - abs passwordB +! + nip wrap100 dup 0= if 1 password +! then ; +: solve ( -- ) 50 input-size 0 do rotate loop + password @ . cr passwordB @ . cr bye ; solve