AdventOfCode/2020/elixir/day3
Adam Millerchip 39c28b5897 Move 2020 elixir solutions to 2020/elixir in prep for zig 2022-08-11 16:22:22 +09:00
..
README Move 2020 elixir solutions to 2020/elixir in prep for zig 2022-08-11 16:22:22 +09:00
day3part1.exs Move 2020 elixir solutions to 2020/elixir in prep for zig 2022-08-11 16:22:22 +09:00
day3part2.exs Move 2020 elixir solutions to 2020/elixir in prep for zig 2022-08-11 16:22:22 +09:00
input Move 2020 elixir solutions to 2020/elixir in prep for zig 2022-08-11 16:22:22 +09:00

README

Day 3 Notes

+--------+
| Part 1 |
+--------|

$ elixir day3part1.exs
Travelled (969, 323) and encountereed 270 trees

Thoughts:

Input repeats, so use Stream.cycle/2.
Need to keep track of the x-offset, pass it to Enum.at/2.


+--------+
| Part 2 |
+--------|

$ elixir day3part2.exs
2122848000

Thoughts:

Modify original answer to take x and y velocity.
Can just pass x velocity in as before.
Use Enum.take_every/2 to skip unneeded rows for y velocity.

+------------------+
| Overall Thoughts |
+------------------+

Pretty simple, because Stream.cycle/2 takes care of the tricky bit.
Thankfully I answered part 1 in a way that made part 2 just a small change to add Enum.take_every/2.
In part 1, was tracking the travelled distance in antipication for part 2, but turns out it wasn't needed,
so stopped tracking the y value in the accumulator for part 2.