diff options
author | Leah Neukirchen <leah@vuxu.org> | 2021-12-22 19:17:02 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2021-12-22 19:17:02 +0100 |
commit | d424225868bdb90da017535d0344757ad3bc4021 (patch) | |
tree | 57896a1e5d95daee122f9b64a7b2473d230b586c /day21.bqn | |
parent | 2a3c0e7c55f644f7af7b8a814357dc6942ed3aac (diff) | |
download | adventofcode2021-d424225868bdb90da017535d0344757ad3bc4021.tar.gz adventofcode2021-d424225868bdb90da017535d0344757ad3bc4021.tar.xz adventofcode2021-d424225868bdb90da017535d0344757ad3bc4021.zip |
day21
Diffstat (limited to 'day21.bqn')
-rw-r--r-- | day21.bqn | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/day21.bqn b/day21.bqn new file mode 100644 index 0000000..c19e7f3 --- /dev/null +++ b/day21.bqn @@ -0,0 +1,19 @@ +#start ← 4‿8 +start ← 3‿10 + +scores ← +` {𝕩+10×𝕩=0} 10| start +` (+´)⎉1 200‿2‿3 ⥊ 1+↕100 +end ← ⊑ / (»⊸<∨`) «⥊scores≥1000 +loser ← end ⊑ ⥊scores +roll ← 3×2+ end +•Show loser × roll + +Move ← { ⟨roll,player,⟨pos,score⟩⟩: + pos2 ← {1+10|roll+𝕩-1}⌾(player⊸⊑) pos + ⟨pos2, score + pos2 × player=↕≠pos2⟩ +} +f ← 3↓<˘⍉(↕∘≠ ≍ ⊣) ≠¨⊔+˝⍉>⥊1+↕3⥊3 +Play ← { + ⟨player,⟨pos,score⟩⟩: ∨´score ≥ 21 ? score ≥ 21 ; + ⟨player,st⟩: +´ { ⟨val,frq⟩: frq × Play (¬player)‿(Move val‿player‿st) }¨ f +} +•Show ⌈´ Play 0‿⟨start,⟨0,0⟩⟩ |