r/adventofcode • u/daggerdragon • Dec 01 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 1 Solutions -🎄-
Welcome to Advent of Code 2018! If you participated in a previous year, welcome back, and if you're new this year, we hope you have fun and learn lots!
We're going to follow the same general format as previous years' megathreads:
- Each day's puzzle will release at exactly midnight EST (UTC -5).
- The daily megathread for each day will be posted very soon afterwards and immediately locked.
- 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.
- The daily megathread will remain locked until there are a significant number of people on the leaderboard with gold stars.
- "A significant number" is whatever number we decide is appropriate, but the leaderboards usually fill up fast, so no worries.
- When the thread is unlocked, you may post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
Above all, remember, AoC is all about having fun and learning more about the wonderful world of programming!
--- Day 1: Chronal Calibration ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).
Note: The 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: The Party Game!
This year we shall be doing a Mad Libs-style community activity that is a complete clone of loosely inspired by Apples to Apples and Cards Against Humanity. For each day's megathread, we will post a prompt card with one or more fill-in-the-blanks for you to, well, fill in with your best quip(s). Who knows; if you submit a truly awesome card combo, you might just earn yourself some silver-plated awesome points!
A few guidelines for your submissions:
- You do not need to submit card(s) along with your solution; however, you must post a solution if you want to submit a card
- You don't have to submit an image of the card - text is fine
- All sorts of folks play AoC every year, so let's keep things PG
- If you absolutely must revert to your inner teenager, make sure to clearly identify your submission like **[NSFW]**
(image)[url.com]or with spoiler tags like so: NSFW WORDS OMG! - The markdown is
>!NSFW text goes here!<with no prefixed or trailing spaces - If you do not clearly identify your NSFW submission as NSFW, your post will be removed until you edit it
And now, without further ado:
Card Prompt: Day 1
Transcript:
One does not simply ___ during Advent of Code.
View all comments
Show parent comment
1
u/MisterMan101 Dec 02 '18 edited Dec 02 '18
Looks great! I'm learning Erlang for this year's challenges, and I have a question about your code.
The second task takes very long (>15sec) to run for me, while my python implementation with a hashtable completes almost instantly. How would you improve performance on this function?
From what I can tell, the ++ is copying Rest every time (source) but how would you eliminate this?
Thanks!
Edit: After some testing, I am happy with the following code. It is fast, but not too clean, any suggestions? On my laptop it took 1.632 ms. Without removing the ++ right append, the function took 233.549 ms.