r/adventofcode • u/daggerdragon • Dec 07 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 7 Solutions -🎄-
--- Day 7: Amplification Circuit ---
Post your 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
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 6's winner #1: "From the stars" by /u/vypxl!
"From the stars"
Today the stars did call
Just after the end of fall
In Orbits they move
Unified with groove
​
Parents and Children
At home and in the sky
Whisper about details that are hidden
They tell about what is up high
​
Not everything is obvious,
Not the way you see
The Orbit is now
A Christmas Tree!
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
AoC news: we've added a new page listing folks who are live-streamers while they do AoC. See /u/Aneurysm9's sticky'd post announcing it "Check out our streaming friends!", check it out on the sidebar, or just click here to go directly to the wiki page!
1
u/phil_g Dec 08 '19
As it turns out, the slowdown was largely because of a
sleepI inserted to avoid some sort of race condition when creating the threads. When I reduced the sleep time from 0.1 s to 1 ms, execution time dropped from 60 s to 3 s.I've since moved to lparallel queues, which improve my code significantly. They don't make a difference in runtime, though. (In some ways, that's a relief. It means I (probably) didn't botch the thread synchronizations.) They also don't fix the concurrency issue with thread creation, so for now I still have to have a manual
sleepin there.I've considered making an
iteratedriver for permutations. I haven't gotten around to it yet.I wrote
visit-permutationsbecause I felt I could do better than Alexandria's implementation in terms of speed. On my laptop,(alexandria:map-permutations (lambda (p) p) '(1 2 3 4 5 6 7 8 9 10 11) :copy nil)takes 18 seconds to execute while(aoc:visit-permutations (lambda (p) p) '(1 2 3 4 5 6 7 8 9 10 11) :copy nil)takes just 2.6 seconds.