misc

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

commit b6585fc1e273cf2943ff9ec9a2a465f104bd1889
parent d417e5cdc57ae679fba78f20702c0dd9677f1fa0
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Tue,  5 Jul 2022 11:58:29 -0700

forthy forth

Diffstat:
Aaoc1.f | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/aoc1.f b/aoc1.f @@ -0,0 +1,30 @@ +( advent of code 2021 day 1 in UF forth v2 ) +( http://www.call-with-current-continuation.org/uf/uf.html ) + +h# 5000 constant filespace + +: readnum + ( push char to stack [awkward] ) + 0 ( return val ) + begin + filespace 1 fileread filespace c@ + swap over h# 0a <> and while ( not [newline or eof] ) + h# 30 - swap 10 * + ( convert ascii val ) + repeat + drop +; + +" input.txt" filename + +: solve + 0 + readnum + 2000 1 do + readnum dup -rot > 0<> 1+ rot + + swap + loop + drop +; + +solve . +