From: Ben Harris Date: Sat, 25 May 2024 23:09:14 +0000 (+0100) Subject: 18a done X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=1a22be4995ec0a5877bbefe1d88301882ded1f9a;p=aoc-2022.git 18a done --- diff --git a/18/18a.bqn b/18/18a.bqn new file mode 100644 index 0000000..0d0e06f --- /dev/null +++ b/18/18a.bqn @@ -0,0 +1,23 @@ +Split←{ + blocknums ← +`𝕨 + # Set entries in blocknums to -1 when they correspond with delimiters. + blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums + blocknums⊔𝕩 +} + +Prep←{ + cubes←{ + •ParseFloat¨(','=𝕩)Split 𝕩 + }¨𝕩 + # "2" here allows a margin for shifting into + droplet←(2+⌈˝>cubes)⥊0 + droplet↩1¨⌾(cubes⊸⊑)droplet +} + +Main←{ 𝕊 droplet: + # We assume that all co-ordinates are strictly positive. + NSurfacesInDir←{ +´⥊𝕩≠»𝕩 } + +´{NSurfacesInDir ⍉⍟𝕩 droplet}¨↕=droplet +} + +•Show Main Prep •file.Lines ⊑•args