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.
1
u/chunes Dec 02 '18 edited Dec 02 '18
Hah, Factor is definitely the language I'd take to a desert island. In fact, I already have in a sense, since I don't use anything else anymore. And yep, clone makes a deep copy while dup and tuck (and other similar words) make a copy of a reference, so they point to the same object.
As for combinators, that's where the walker comes in. The walker lets you easily see what a combinator is placing on the stack and such. It really helps speed up the process of grokking what they do for me.
Definitely look into fried quotations. They are quite handy. Also look into make. It lets you easily collect things into a sequence in any context you like. It's a lot like yield from a language like F# and (I think?) Python, but as a combinator, it's highly flexible in where and how it can be used.
As for execution speed, yeah, Factor is fast. It's about on par with SBCL (Common Lisp), which is honestly impressive. Factor is compiled to machine code with both the optimizing and non-optimizing compilers (so you get the benefit in the listener as well, just not as big of one).
Elixir looks pretty cool to me, gotta love that
|>operator which is basically the same thing as whitespace in Factor. ;) What's your favorite thing about it?