From 90acf50b07732003866574e22f64483df096c6c8 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Fri, 7 Dec 2018 12:41:25 +0000 Subject: [PATCH] Day 6 solution. --- p6.dyalog | 7 +++++++ p6.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 p6.dyalog create mode 100644 p6.txt diff --git a/p6.dyalog b/p6.dyalog new file mode 100644 index 0000000..2945751 --- /dev/null +++ b/p6.dyalog @@ -0,0 +1,7 @@ +p←↑⍎¨⊃⎕NGET'p6.txt'1 +g←{1=≢z←⍸t=⌊/t←+/|p-⍤1⊢⍵:⊃z⋄¯1}¨⍳⌈⌿p +sort←{(⊂⍋⍵)⌷⍵} +a←sort{⍺,≢⍵}⌸,g +b←sort{⍺,≢⍵}⌸,1 1↓¯1 ¯1↓g +⌈/⊢/↑(↓a)∩↓b ⍝ part 1 ++/,{10000>+/,|p-⍤1⊢⍵}¨⍳⌈⌿p ⍝ part 2 diff --git a/p6.txt b/p6.txt new file mode 100644 index 0000000..fb5384c --- /dev/null +++ b/p6.txt @@ -0,0 +1,50 @@ +227, 133 +140, 168 +99, 112 +318, 95 +219, 266 +134, 144 +306, 301 +189, 188 +58, 334 +337, 117 +255, 73 +245, 144 +102, 257 +255, 353 +303, 216 +141, 167 +40, 321 +201, 50 +60, 188 +132, 74 +125, 199 +176, 307 +204, 218 +338, 323 +276, 278 +292, 229 +109, 228 +85, 305 +86, 343 +97, 254 +182, 151 +110, 292 +285, 124 +43, 223 +153, 188 +285, 136 +334, 203 +84, 243 +92, 185 +330, 223 +259, 275 +106, 199 +183, 205 +188, 212 +231, 150 +158, 95 +174, 212 +279, 97 +172, 131 +247, 320