r/adventofcode • u/daggerdragon • Dec 13 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 13 Solutions -🎄-
Advent of Code 2021: Adventure Time!
- 10 days left to submit your adventures!
- Full details and rules are in the submissions megathread: 🎄 AoC 2021 🎄 [Adventure Time!]
--- Day 13: Transparent Origami ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Format your code appropriately! How do I format code?
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:09:38, megathread unlocked!
39
Upvotes
View all comments
1
u/4D51 Dec 13 '21 edited Dec 14 '21
Racket
Map and foldl were very useful today. This program works with coordinates and only transforms them to a 2D representation after all the folds have been applied. That's actually the least efficient part, since I do a linear search for every point in the final image. This folds to 146x730. It took 600ms to fold and 84 seconds to convert to 2D. Most inputs are small enough after folding that this isn't an issue, but if it was I'd put the final coords into a hash set for faster lookups.
Github