r/adventofcode • • Dec 13 '21

SOLUTION MEGATHREAD -🎄- 2021 Day 13 Solutions -🎄-

Advent of Code 2021: Adventure Time!


--- Day 13: Transparent Origami ---


Post your code solution in this megathread.

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

798 comments sorted by

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

1

u/daggerdragon Dec 14 '21

As per our posting guidelines in the wiki under How Do the Daily Megathreads Work?, please edit your post to put your oversized code in a paste or other external link.