aoc-forth

Advent of code solutions in UF forth
git clone git://git.alexwennerberg.com/aoc-forth
Log | Files | Refs | README

commit b7f4f74ee97364af4aba220479dad379c945c562
Author: alex wennerberg <awennerb@twitch.tv>
Date:   Tue, 23 Aug 2022 09:43:51 -0400

Day 1 + readme

Diffstat:
A2021/day1.fs | 27+++++++++++++++++++++++++++
AREADME.md | 15+++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/2021/day1.fs b/2021/day1.fs @@ -0,0 +1,26 @@ +h# 5000 constant filespace + +: readnum + 0 ( return val ) + begin + ( push char to stack [awkward] ) + 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 . +\ No newline at end of file diff --git a/README.md b/README.md @@ -0,0 +1,15 @@ +# Forth AOC + +Advent of Code solutions in [UF +forth](http://www.call-with-current-continuation.org/uf/uf.html) + +Forth is a stack-based programming language. It is extremely small. UF is a Forth targeting the +[uxn/varvara](https://100r.co/site/uxn.html) virtual computer. + +I am going to try to work through 2021 using this language/environment as an exercise, and +in preparation for 2022. + +A notable challenge will be that I only have access to 64kb of memory. May have to +use swap space of some sort. + +Running instructions TBD