Initial commit

This commit is contained in:
Dimitri Lozeve 2024-11-12 21:43:32 +01:00
commit f242d2b0df
420 changed files with 62521 additions and 0 deletions

9
2020/day07/day07.dyalog Normal file
View file

@ -0,0 +1,9 @@
⎕IO←0
p←'(^|\d )\w+ \w+ bag'⎕S'&'¨⊃⎕NGET'input'1
bags←⊃¨p
edges←1↓¨p
adj←edges∘.{0⌈48-⍨⎕UCS⊃⊃(/¨(⊂⍵)⍷¨⍺)/}bags
gold←bags⊂'shiny gold bag'
¯1+({∪⍵,⊃¨⍸1⌊adj[;⍵]}⍣≡)1gold ⍝ Part 1
inside←{⊃{∊1↓¨⍸adj[⍵;]}¨⊂⍵}
¯1+⍴∊{(inside⍣⍵)1gold}¨100 ⍝ Part 2