chiark / gitweb /
18a done
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 25 May 2024 23:09:14 +0000 (00:09 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 25 May 2024 23:09:14 +0000 (00:09 +0100)
18/18a.bqn [new file with mode: 0644]

diff --git a/18/18a.bqn b/18/18a.bqn
new file mode 100644 (file)
index 0000000..0d0e06f
--- /dev/null
@@ -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