AdventOfCode/day16
2020-12-16 23:57:57 +09:00
..
day16part1.exs Tidy Day 16 2020-12-16 23:57:57 +09:00
day16part2.exs Tidy Day 16 2020-12-16 23:57:57 +09:00
input Day 16 Initial Version - will tidy up later 2020-12-16 20:54:50 +09:00
README Tidy Day 16 2020-12-16 23:57:57 +09:00

Day 16 Notes

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

$ elixir day16part1.exs
28884

Thoughts:

Slightly complex input to parse this time. Most of the solution is parsing.
The actual logic: Use Enum.any?(rules) to check if a ticket satisfies any of the rules.
Filter those results by only those that are not valid.
Flat map the filtered tickets, to get a flat list of fields.
Sum the result.


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

$ elixir day16part2.exs
1001849322119

Thoughts:

More complicated as I initially thought, because most columns are valid for more than
one rule. Interestingly no column is valid for the *same* number of rules, which makes me
think this is a manifestation of some maths problem I don't know about.

Anyway, solve it by:
* Transposing the tickets into lists of "columns"
* Match each column against the rules it satisfies
* Starting with the column that only matches one rule, mark that column as solved.
* Continue for subsequent rules, removing the solved columns from the set of rules it
  satisfies as we go.

I'm sure there is a more efficient way to handle this rather than the building up n lists
and then for each entry removing that from the remaining lists.


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

Spent a bit too long on silly mistakes in this one. Think I need to consider my development
process to help avoid making errors, especially when dealing with multiple related data structures
/ representation of those data structures.

Also, I'm finding these daily puzzles a bit too distracting from work. I think after today
I'm going to relegate them to the weekend. Doing them in the evenings has too much potential
to spill over into the next day.