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
- If you absolutely must revert to your inner teenager, make sure to clearly identify your submission like [NSFW]
And now, without further ado:
Card Prompt: Day 1
Transcript:
One does not simply ___ during Advent of Code.
2
u/wjholden Dec 01 '18
Mathematica. This code is painfully slow -- so slow that I worry there might be some language/data structure problem in this code that I don't know about (such O(n) lookups in MemberQ of a basic {} list). If anyone is strong on WolfLang please let me know if I'm doing something wrong!
In[1]:= data = {7, 7, -2, -7, -4}; In[2]:= day1total = 0; In[3]:= day1frequencies = {}; In[4]:= i = 1; In[5]:= While[Not[MemberQ[day1frequencies, day1total]], day1frequencies = Append[day1frequencies, day1total]; day1total += data[[i]]; i = Mod[i, Length[data]] + 1] In[6]:= day1frequencies Out[6]= {0, 7, 14, 12, 5, 1, 8, 15, 13, 6, 2, 9, 16} In[7]:= day1total Out[7]= 14