about summary refs log tree commit diff
path: root/day02.bqn
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2021-12-03 12:21:46 +0100
committerLeah Neukirchen <leah@vuxu.org>2021-12-03 12:21:46 +0100
commit278956ae9652193a2231614b533417eefb1523cb (patch)
treec0f4ef66b4be9bbf511d2a1cba7c2691d782e307 /day02.bqn
parent9a76ba31c25d5adfacc41d5c7282fc48fe1113a6 (diff)
downloadadventofcode2021-278956ae9652193a2231614b533417eefb1523cb.tar.gz
adventofcode2021-278956ae9652193a2231614b533417eefb1523cb.tar.xz
adventofcode2021-278956ae9652193a2231614b533417eefb1523cb.zip
day02
Diffstat (limited to 'day02.bqn')
-rw-r--r--day02.bqn16
1 files changed, 16 insertions, 0 deletions
diff --git a/day02.bqn b/day02.bqn
new file mode 100644
index 0000000..ae2c60d
--- /dev/null
+++ b/day02.bqn
@@ -0,0 +1,16 @@
+d←•FLines"day02"
+c←⊑¨d
+n←'0'-˜¯1⊑¨d
+
+pos←+´n×'f'=c
+aim←+`n×1-˜"ufd"⊐c
+depth←⊑⌽aim
+•Out pos×depth
+
+depth2←+´n×aim×'f'=c
+•Out pos×depth2
+
+{ # Golfed:
+•Out (p←+´m←n×c=9)×⊑⌽a←+`(n←'0'-˜¯1⊑¨d)×1-˜4‿9‿6⊐c←≠¨d←•FLines"day02"
+•Out p×+´a×m
+}