Expand description
§Transparent Origami
There are 2 possible approaches to tracking the position of dots after each fold:
- A
HashSetthat will collapse duplicate entries - An array of sufficient dimensions to track every possible coordinate.
We will use both approaches for speed, the first in part 1 and the second in part 2.
For part 2 we can determine the final size of the paper by taking the last x and y coordinates from the fold instructions. It’s then faster and more convenient to process each point completely and update the final location, than to step through intermediate folds.
Structs§
Enums§
Functions§
- fold_
horizontal 🔒 - Fold point at
xcoordinate, doing nothing if the point is to the left of the fold line. - fold_
vertical 🔒 - Fold point at
ycoordinate, doing nothing if the point is above the fold line. - parse
- Parse the input into collections of
PointandFoldstructs. - part1
- Fold once then count dots. The sample data folds along
yand my input folded alongxtesting both possibilities. - part2
- Decode secret message.