Skip to content

Instantly share code, notes, and snippets.

@xpqz
Last active July 15, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpqz/281587aaa9618331396b73da3695f49b to your computer and use it in GitHub Desktop.
Save xpqz/281587aaa9618331396b73da3695f49b to your computer and use it in GitHub Desktop.
⍝ https://adventofcode.com/2017/day/24
DAY24←⍎¨¨'/'(≠⊆⊢)¨⊃⎕NGET'data/2017/24.txt'1
Find←{(a b)←↓⍉↑↑⍺⋄⍺[(⍸⍵=a)∪⍸⍵=b]}
∇ r←components Day24p1 args;path;pins;strongest;c;bridge
(path pins)←args
strongest←path
:For c :In (components~path) Find pins
bridge←(components~c)Day24p1 (⊂(path,⊂c)),c {r←⍺~⍵⋄0=≢r:⊃⍺⋄⊃r} pins ⍝ Handle when both pins are equal
:If (+/∊bridge)>+/∊strongest
strongest←bridge
:EndIf
:EndFor
r←strongest
+/∊DAY24 Day24p1 (⊂0 0) 0 ⍝ Part 1: 1511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment