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 4101bb0396495ee8ae77a358f85b20641583f3a8
parent 5da7c6b4a1b334aaae6a7820c4440542babe3ec3
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  2 Jan 2026 23:30:59 -0800

clean up day 1

Diffstat:
M01.f | 22++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/01.f b/01.f @@ -2,17 +2,19 @@ 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 ; +: floor-mod ( n1 n2 -- n ) /mod swap 0< if 1- then ; \ solution variable password -variable passwordB \ for short -: rotation ( a u -- n ) over c@ [char] O - 3 / -rot 1 /string s>n * ; -: 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 ; +variable passwordB +: turn-val ( a u -- n ) over c@ [char] O - 3 / -rot 1 /string s>n * ; +: wrap-100 ( n -- n ) dup 100 floor-mod 100 * - ; +: turn ( old -- new ) dup query tibs turn-val >r r@ + + ( old new ) + 2dup r> 0< if 1- swap 1- then \ border fix + 100 floor-mod swap 100 floor-mod - abs passwordB +! + nip ( new ) wrap-100 dup 0= if 1 password +! then ; +: solve ( -- ) 50 input-size 0 do turn loop drop + password @ . cr + passwordB @ . cr bye ; solve