Well, we're off to a running start! Since the leaderboard is safely locked, we can go ahead and post our solutions now!
Day 1 - The Problem
Looks like Santa got himself in a bit of trouble this year! Seems like we're not dealing with time shenanigans, printer trouble, high-precision clock fueling or weather machine woes. This year we need to get Santa and his sleigh back from the edge of space.
But first... we need to get to him. Getting to him requires fuel. Let's calculate how much we'll need to make the trip.
Part 1 of this problem was a nice straightforward warmup. Part 2 was only a little bit trickier than the first, but I overthought it and gave myself the wrong answer anyway.
Ongoing Meta
Dev.to List of Leaderboards
-
120635-5c140b9a
- provided by Linda Thompson
If you were part of Ryan Palo's leaderboard last year, you're still a member of that!
If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your code and any theming or notes youβd like me to add. (You can find your private leaderboard code on your "Private Leaderboard" page.)
I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and Iβll fix it ASAP.
There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" and a language specific one if you want.
Neat Statistics
I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?
Top comments (33)
I would love to be part of some DEV leaderboards! I'm not showing myself as part of any right now, and am more than willing to use my own private one as a DEV-centric one if we need it. :) Do we have a way to share those so we can start joining?
I'll be doing my solutions in JavaScript - they're usually fairly verbose, since it helps me think better that way. lol :) So likely pretty beginner-friendly!
Here's day 1's solutions:
Ooh this is a great use of
do...while
. I went with the less elegant nestedif
for mine πPart 1 (JavaScript)
Part 2 (JavaScript)
Still works well! As long as it gets you the answer, it's good! :)
I saw someone use a ternary operator, and was super impressed. Might refactor mine later today to test that. :) Didn't even think of it!
Also, I couldn't resist the idea of the poem challenge they're doing on the subreddit, so I wrote an acrostic. :) Sharing here as well!
Very nice, I need to step my JS game up!
This post may help you regarding DEV leaderboards -
Want to Run DEV's Advent of Code?
Ryan Palo γ» Nov 11 γ» 1 min read
Post it here and I'll add it to the post and on further days posts! Go to you private leaderboard page and copy the code into a reply.
Alright, here's the code - 120635-5c140b9a.
We can make it for basically anyone on DEV, or we can focus it towards more beginner-friendly if we'd like - whatever works best for everyone!
Updated the post to include it! Thank you!
Awesome! Thanks for creating a leaderboard for DEV.
I'm in.
My kotlin solution.
I'm going to clean this up to avoid imperative style and post it as a reply to this comment.
github.com/jbristow/adventofcode/t...
This part 2 solution is much more elegant, and leverages monads.
I didn't even think about using a
max
function - that would have been so much cleaner than making two functions!I love cleaning these up into more elegant forms almost as much as I love just getting the solution banged out!
Solution in Clojure:
Yay, Advent of Code is back. I'm not going to stick to one programming language this year, in fact I'm going to try to use lots, even some I've not used before. I'm not quite hardcore enough to do the different-language-every-day challenge however. Not this year anyway.
Day 1 in Haskell:
Once it was solved I did it again in Python just for fun:
And in the spirit of what I wrote at the top, I did it once more in Julia, my first ever code in that language. First impressions very positive and interestingly it came out shortest. I love the built-in unit testing.
Hey folks - for anyone who's joined the leader board so far - I have a question!
So there are two main ways to sort our leader board, and I'm wondering which option would be best for us.
Option 1 - It counts how many people belong to the leader board (n), then the first user to get each star gets N points, the second gets N-1, and the last gets 1.
Option 2 - It counts how many stars you have, and then any ties are broken by the time you got the star. So if everyone gets all of the stars, the ones who get them the fastest are higher up.
I think either way is likely fine, but feel like maybe the star sort option might be best - it seems like it would encourage completion of the challenges more so than simply getting them done fastest, but still includes some speed needed to be higher up. Would love to hear some other thoughts on this, and whichever option seems most popular is what I'll sort it by!
I like option 2 a bit better. I'd rather see the people that manage to solve the more complicated problems at the top than those who solved the first few problems the fastest.
Same here, option 2 sounds better.
In the check for 5 digits or less.
My solution using Rust.
This was a good ramp into the month! Here's my Rust solution. :)
This is my solution to Part 1 in Ruby - working on Part 2!
I joined the leaderboard, but since I'm in a EU timezone and only have time to work on them in the evenings I'm expecting my scores to be quite low π
Here's my solution for day 1 with Python (explained my thinking behind it here):
Part 1:
Part 2:
Bit late to the party!
Here is my solution in swift. Incase anyone would like followup code can be found here in Github