From e481f444938abba7d944706f6681d1ab5e235f48 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 26 May 2024 14:26:54 +0100 Subject: [PATCH] 19b done --- 18/18b.bqn | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 18/18b.bqn 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: + (