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 one and the second in part two.
For part two we can determine the final size of the paper by taking the last x and y coordinates from the fold instructions. Because each fold cuts the remaining paper in half, the layout of points that map to the same condensed positions is periodic. It’s faster and more convenient to process each point completely using modular math to go straight to the condensed position without worrying about any intermediate folds.
Structs§
Enums§
Functions§
- apply_
fold 🔒 - parse
- Parse the input into collections of
PointandFoldstructs. - part1
- Fold once then count dots. The sample data folds along
yand my input folded alongx, testing both possibilities. - part2
- Decode secret message.
- reflect 🔒
- All larger folds repeat a periodic mapping pattern given by the final fold, so a single modulo followed by a reflection back into range replaces every intermediate fold.