From 233729163f144d34945264af37ce213686c3d711 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Fri, 14 Dec 2018 14:42:11 +0000 Subject: [PATCH] Day 14 solution based on JW Buitenhuis's K solution. --- p14.dyalog | 12 ++++++++++++ p14.txt | 1 + 2 files changed, 13 insertions(+) create mode 100644 p14.dyalog create mode 100644 p14.txt diff --git a/p14.dyalog b/p14.dyalog new file mode 100644 index 0000000..b05bced --- /dev/null +++ b/p14.dyalog @@ -0,0 +1,12 @@ +⎕IO←0 +input←⍎⊃⊃⎕NGET'p14.txt'1 +scores←3 7 + +nxt←{(≢scores)|⍵+1+cur⊣scores,←(t<10)↓10 10⊤t←+/cur←scores[⍵]} +super←{nxt⍣(⌈0.2×≢scores)⊢⍵} +pos←super⍣{input<¯10+≢scores}0 1 +∊⍕¨r←10↑input↓scores ⍝ part 1 + +match←⍎¨⍕input +{}super⍣{∨/match⍷scores}pos +⊃⍸match⍷scores ⍝ part 2 diff --git a/p14.txt b/p14.txt new file mode 100644 index 0000000..ff462dc --- /dev/null +++ b/p14.txt @@ -0,0 +1 @@ +640441