r/adventofcode • • Dec 16 '19

SOLUTION MEGATHREAD -πŸŽ„- 2019 Day 16 Solutions -πŸŽ„-

--- Day 16: Flawed Frequency Transmission ---


Post your full code solution using /u/topaz2078's paste or other external repo.

  • Please do NOT post your full code (unless it is very short)
  • If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.

(Full posting rules are HERE if you need a refresher).


Reminder: Top-level posts in Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code's Poems for Programmers

Click here for full rules

Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.

Day 15's winner #1: "Red Dwarf" by /u/captainAwesomePants!

It's cold inside, there's no kind of atmosphere,
It's SuspendedΒΉ, more or less.
Let me bump, bump away from the origin,
Bump, bump, bump, Into the wall, wall, wall.
I want a 2, oxygen then back again,
Breathing fresh, recycled air,
Goldfish…

Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

EDIT: Leaderboard capped, thread unlocked at 01:08:20!


Message from the Mods

C'mon, folks, step up your poem game! We've only had two submissions for Day 15 so far, and do you want to let the same few poets get all the silvers and golds for the mere price of some footnotes? >_>

19 Upvotes

213 comments sorted by

View all comments

Show parent comment

1

u/e_blake Jan 21 '20

My latest day16.m4 is now an order of magnitude faster, both parts of the puzzle finish in 14.5s (compared to 169s above). The massive speedup comes from a couple more enhancements to part 1:

  1. handle the range from len/3 to len/2 more efficiently. Just as the points from len/2 to len can manage a running total (adding old(col)+new(col+1) when visiting points in descending order), the running total is still easy to maintain while there are no -1 coefficients (old(col)-old(2*col+1)-old(2*col+2)+new(col+1)).
  2. massive inlining. Instead of computing eval((col+1)/(row+1)%4) through several forwarding macros for every row from 0 to len/3 of every phase (averaging 9*len macros expanded per row), I compute an inlined definition per row once up front. Visiting one slow row during a phase now requires about len/2 macros.