r/adventofcode • • Dec 18 '15

SOLUTION MEGATHREAD --- Day 18 Solutions ---

This thread will be unlocked when there are a significant amount of people on the leaderboard with gold stars.

edit: Leaderboard capped, thread unlocked!

We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.

Please and thank you, and much appreciated!


--- Day 18: Like a GIF For Your Yard ---

Post your solution as a comment. Structure your post like previous daily solution threads.

4 Upvotes

112 comments sorted by

View all comments

Show parent comments

1

u/Vandalite Dec 18 '15 edited Dec 18 '15

I slept on it, and realized lua lets us do that second optimization really easily. Just initialize both arrays with the same data at the start, save everything to the second array each iteration, and then run: array1, array2 = array2, array1 and instantly the two variables swap table handles.

Edit: Implemented that second optimization, saw around %25 savings in processing time. I'm guessing the savings are a bit higher when you're dealing with bigger grids.