Expand description
Advent of Code 2015 Day 3: https://adventofcode.com/2015/day/3
I originally misread the instructions for this challenge and thought that
the prompt wanted to know how many houses received more than one present
but after getting the wrong answer realized that the prompt simply wanted
to know the total number of houses that received a present. I decided to
keep the initial implementation that tracks the number of presents that a
house receives, but it may be more efficient or performant to ignore how
many presents a house receives and just keep a list of coordinates that
have been visited using e.g., a std::collections::HashSet
.
As it is I’m using a std::collections::HashMap
with tuples of x
,y
coordinates as the key to store the number of presents delivered to the
house at those coordinates. The answer to the challenge then comes from
counting the number of entries in the collection. More advanced answers
(e.g., the number of houses receiving more than one present) can be
determined by analyzing the same result collection.
Functions§
- The solution for the day three challenge.