aoc-forth

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

commit 0c47913ca94bd41591e28550cf21254083be18d5
parent 24ebccd2013c7b899a6e7d5a753644a17b73e7ca
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 27 Aug 2022 10:29:57 -0400

wip stuffs

Diffstat:
M2021/02.fs | 29+++++++++++++++++++++++------
MREADME.md | 2++
2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/2021/02.fs b/2021/02.fs @@ -11,12 +11,15 @@ h# 5000 constant filespace variable xpos variable ydepth +variable aim -: solvea - 1000 0 do readline +: getcommand filespace c@ \ get direction filespace 20 32 scan drop 1+ \ read until space c@ chartonum swap \ get number +; +: solvea + 1000 0 do readline getcommand dup 102 = if \ 'f' over xpos +! then dup 100 = if \ 'd' @@ -25,16 +28,30 @@ variable ydepth over negate ydepth +! then 2drop loop - xpos @ ydepth @ . + xpos @ ydepth @ um* ; -: solveb - 10 +: solveb \ TODO figure out how to store double + s" input02.txt" filename + 1000 0 do readline getcommand + dup 102 = if \ 'f' + over xpos +! + over aim @ * ydepth +! + then dup 100 = if \ 'd' + over aim +! + then dup 117 = if \ 'u' + over negate aim +! + then + xpos @ ydepth @ aim @ . . . cr + 2drop loop + xpos @ ydepth @ .s um* ; : boot s" input02.txt" filename - solvea . cr \ TODO double math?? + solvea d. cr \ TODO double math?? + 0 xpos ! 0 ydepth ! + solveb d. cr bye ; save 02.rom \ Replace with soln number bye diff --git a/README.md b/README.md @@ -20,6 +20,8 @@ uxncli ufx.rom < N.fs uxnemu N.rom ``` +Working on different ways of importing things, some days require helper functions + Some solutions have visualizations, others do not. For those that don't, you can use uxncli part 1 and part 2 solutions will be printed to the console, newline separated