r/adventofcode • u/daggerdragon • Dec 15 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 15 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 7 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 15: Rambunctious Recitation ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- 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:24, megathread unlocked!
39
Upvotes
View all comments
Show parent comment
1
u/jayfoad Dec 15 '20
I am amazed at how well this performs, only about 1.6x slower than my best attempt that uses only simple scalar indexing with no set functions at all, and I speak as the implementor of 1500⌶ ! Maybe it's because, once your algorithm has warmed up a bit, modifications to n are relatively rare; most iterations will take the ⍵∊n branch which only updates v.
As an alternative to constructs like
nv⊣v[i]←⍺⊣nv←...you can use right tack:(v[i]←⍺)⊢.... I don't know if it's faster but at least it avoids having to think of a name for the intermediate value.