Uiua
This is the first one that caused me some headache because I didn't read the instructions carefully enough.
I kept trying to create a sorted list for when all available pages were used, which got me stuck in an endless loop.
Another fun part was figuring out to use memberof (β)
instead of find (β)
in the last line of FindNext
. So much time spent on debugging other areas of the code
Run with example input here
FindNext β β(
β‘1β,
ββ½(β½Β¬)βΈβ
ββ(β‘0β.)
:β(β(β½Β¬β))
)
# find the order of pages for a given set of rules
FindOrder β (
β΄β.
[]
β’(βFindNext|β
(>1β§»))
βββ
)
PartOne β (
&rs β &fo "input-5.txt"
β©Β°β‘Β°βββ‘Β¬β"\n\n".
β(β(β‘βββ @,.)β @\n.β1)
β(βββ @|.)β @\n.
β.
Β€
β(β‘(Β°β‘:)
β:β(Β°ββ)
=2+β©β
β½
FindOrder
βΈβΒ°β‘:
ββ
)
β‘β(β‘βΓ·2β§».)β½β
/+
)
PartTwo β (
&rs β &fo "input-5.txt"
β©Β°β‘Β°βββ‘Β¬β"\n\n".
β(β(β‘βββ @,.)β @\n.β1)
β(βββ @|.)β @\n.
β.
βΒ€β(
β‘(Β°β‘:)
β:β(Β°ββ)
=2+β©β
β½
FindOrder
βΈβΒ°β‘:
ββ©β‘
)
ββ
β(β‘0)(β‘1)β
β‘β(β‘βΓ·2β§».)β½Β¬β‘Β°β‘
/+
)
&p "Day 5:"
&pf "Part 1: "
&p PartOne
&pf "Part 2: "
&p PartTwo