day 2 part 1 done

This commit is contained in:
Nico 2021-12-02 09:19:33 +00:00
parent 00c29ca217
commit 737bd7c239
3 changed files with 1037 additions and 0 deletions

31
day2.retro Normal file
View File

@ -0,0 +1,31 @@
# Day 2: Dive!
## part 1
This one doesn't seem too difficult. Parsing a text file line-by-line and updating 2 variables based on that.
~~~
'depth var
'hpos var
~~~
The `read-move` word is used for every command in the file.
~~~
:read-move (s-) ASCII:SPACE s:split/char
'forward [ s:trim s:to-number @hpos + !hpos ] s:case
'up [ s:trim s:to-number @depth swap - !depth ] s:case
'down [ s:trim s:to-number @depth + !depth ] s:case
;
~~~
And run this on the whole file, printing the results:
~~~
'input2 [ read-move ] file:for-each-line
@depth @hpos * n:put ASCII:LF c:put
~~~
## part 2
TODO

1000
input2 Normal file

File diff suppressed because it is too large Load Diff

6
test2 Normal file
View File

@ -0,0 +1,6 @@
forward 5
down 5
forward 8
up 3
down 8
forward 2