Uiua
After finally deciding to put aside Day 9 Part 2 for now, this was really easy actually. The longest was figuring out how many extra dimensions I had to give some arrays and where to remove those again (and how). Then part 2 came along and all I had to do was remove a single character (not removing duplicates when landing on the same field by going different ways from the same starting point). Basically, everything in the parentheses of the Trails!
macro was my solution for part 1, just that the ^0
was โด
(deduplicate). Once that was removed, the solution for part 2 was there as well.
Run with example input here
Note: in order to use the code here for the actual input, you have to replace =โ
with =โ
โ
because I was too lazy to make it work with variable array sizes this time.
$ 89010123
$ 78121874
$ 87430965
$ 96549874
$ 45678903
$ 32019012
$ 01329801
$ 10456732
.
Adj โ ยค[0_ยฏ1 0_1 ยฏ1_0 1_0]
Trails! โ (
โ=0.
โยค
โก(โกยค)
1
โฅ(โ(โก(โก^0/โโก(+ยค)โยคยฐโก)โAdj
โก(โกโฝยฌโก/++โ=โโ=โ.ยฐโก))
+1โโธโ(โฝ=โ(:โโก))
)9
โโโ
โงป/โโ
)
PartOne โ (
# &rs โ &fo "input-10.txt"
โโตโโ @\n.
Trails!โด
)
PartTwo โ (
# &rs โ &fo "input-10.txt"
โโตโโ @\n.
Trails!โ
)
&p "Day 10:"
&pf "Part 1: "
&p PartOne
&pf "Part 2: "
&p PartTwo