From: Ben Harris Date: Sun, 26 May 2024 13:26:54 +0000 (+0100) Subject: 19b done X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=e481f444938abba7d944706f6681d1ab5e235f48;p=aoc-2022.git 19b done --- diff --git a/18/18b.bqn b/18/18b.bqn new file mode 100644 index 0000000..11afbba --- /dev/null +++ b/18/18b.bqn @@ -0,0 +1,33 @@ +Split←{ + blocknums ← +`𝕨 + # Set entries in blocknums to -1 when they correspond with delimiters. + blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums + blocknums⊔𝕩 +} + +Prep←{ + cubes←{ + •ParseFloat¨(','=𝕩)Split 𝕩 + }¨𝕩 + # We assume that all co-ordinates are non-negative. + # "3" here allows a margin for flow all round the droplet. + droplet←(3+⌈˝>cubes)⥊0 + droplet↩1¨⌾((1+cubes)⊸⊑)droplet +} + +Main←{ 𝕊 droplet: + steam←1⌾(0⊸⊑∘⥊)(≢droplet)⥊0 + Flood1←{ droplet 𝕊 steam: + (¬droplet) ∧ steam ∨ ∨´{(«∨»)⎉𝕩 steam}¨1+↕=𝕩 + } + Flood←{ droplet 𝕊 steams: + (