2020-12-02 05:43:05 +00:00
|
|
|
Day 2 Notes
|
|
|
|
|
|
|
|
------
|
|
|
|
Part1:
|
|
|
|
------
|
|
|
|
|
|
|
|
$ elixir day2part1.exs
|
|
|
|
414
|
|
|
|
|
|
|
|
Thoughts:
|
|
|
|
|
|
|
|
Use a regex to parse the input
|
2020-12-02 05:45:52 +00:00
|
|
|
Huh, can't iterate a string with Enum. Split into a list with String.graphemes/1
|
2020-12-02 05:43:05 +00:00
|
|
|
|
|
|
|
------
|
2020-12-02 05:46:47 +00:00
|
|
|
Part2:
|
2020-12-02 05:43:05 +00:00
|
|
|
------
|
|
|
|
|
|
|
|
$ elixir day2part2.exs
|
|
|
|
413
|
|
|
|
|
|
|
|
Thoughts:
|
|
|
|
|
|
|
|
Convert indices to be zero-based.
|
|
|
|
No xor operator without importing Bitwise? Just write it manually.
|
|
|
|
Initially misread the problem - thought first position must match, and second position must not match,
|
|
|
|
which caused some confusion.
|
|
|
|
Probably rebound to the same variable names a bit too much - should work on clearer variable names.
|
2020-12-02 07:20:40 +00:00
|
|
|
|
|
|
|
After reading the elixir forum thread, String.at would have been fine for Part 2.
|
|
|
|
https://elixirforum.com/t/advent-of-code-2020-day-2
|