Day 1: Historian Hysteria
Megathread guidelines
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://blocks.programming.dev if you prefer sending it through a URL
FAQ
- What is this?: Here is a post with a large amount of details: https://programming.dev/post/22323136
- Where do I participate?: https://adventofcode.com/
- Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
36 Comments
lwhjp@lemmy.sdf.org · 7 pts · 1y
Haskell
Plenty of scope for making part 2 faster, but I think simple is best here. Forgot to sort the lists in the first part, which pushed me waaay off the leaderboard.
mykl@lemmy.world · 7 pts · 1y
Uiua
For entertainment purposes only, I'll be trying a solution in Uiua each day until it all gets too much for me...
janAkali@lemmy.one · 4 pts · 1y
Nim
I've got my first sub-1000 rank today (998 for part 2). Yay!
Simple and straightforward challenge, very fitting for 1st day. Gonna enjoy it while it lasts.
Codeberg repo
Rin@lemm.ee · 4 pts · 1y
Gobbel2000@programming.dev · 4 pts · 1y
Rust
Right IDs are directly read into a hash map counter.
Leavingoldhabits@lemmy.world · 3 pts · 1y
Iβm quite inexperienced as a programmer, I learned most of the basic concepts from playing human resource machine and 7 billion humans. After mucking about writing some CLI utilities in Perl and python, Iβve decided to give rust a go.
Part 1
Part 2
MalachiAzrael@sh.itjust.works · 3 pts · 1y
Python
::: spoiler Part 1
::: ::: spoiler Part 2
:::
I am sure there were better ways to do this, this was just the first way in my head, in the order it appeared
proved_unglue@programming.dev · 3 pts · 1y
Kotlin
No π for Kotlin here?
the_beber@lemm.ee · 1 pts · 1y
I have another Kotlin (albeit similar) solution:
It's a bit more compact. (If you take out the part that actually calls the functions on the (test-)input.)
proved_unglue@programming.dev · 2 pts · 1y
Thanks! I like the
Pairdestruction andzip().sumOf()approach. I'm relatively new to Kotlin, so this is a good learning experience. πvole@lemmy.world · 3 pts · 1y
Raku
I'm trying warm up to Raku again.
::: spoiler Solution github
:::
I'm happy to see that Lemmy no longer eats Raku code.
hades@lemm.ee · 3 pts · 1y
sjmulder@lemmy.sdf.org · 3 pts · 1y
Solution in C
Part 1 is a sort and a quick loop. Part 2 could be efficient with a lookup table but it was practically instant with a simple non-memoized scan so left it that way.
mcmodknower@programming.dev · 1 pts · 1y
You are using some interesting techniques there. I never imaged you could use the result of == for adding to a counter.
But how did you handle duplicates in part 2?
sjmulder@lemmy.sdf.org · 1 pts · 1y
Iβm not sure if I understand the question correctly but for every number in the left array I count in the right array. That means duplicate work but shrug π
ace@lemmy.ananace.dev · 3 pts · 1y
Not going to push hard on these first days (fever being a reason), so I slept in quite a bit before looking at the problem. ::: spoiler C#
:::
mcmodknower@programming.dev · 2 pts · 1y
Solution in ruby
This is my third program in ruby after the ruby tutorial and half of the rails tutorial, so don't expect anything too good from it.
Also i did this today since i had time, i will probably not comment every day.
morrowind@lemmy.ml · 2 pts · 1y
fyi for lines 14-22 you an use
.absinstead of checking for negatives and.suminstead of doing it manually. Check my crystal solution to see what I meanmcmodknower@programming.dev · 1 pts · 1y
That is good to know, thank you.
bugsmith@programming.dev · 2 pts · 1y
I'm late to the party, as usual. Damned timezones. This year I'm going to tackle with a small handful of languages, but primarily Elixir and Gleam. This is my first time trying this languages in earnest, so expect some terrible, inefficient and totally unidiomatic code!
Here's day one:
Elixir
rwdf@lemmy.world · 2 pts · 1y
Go
TunaCowboy@lemmy.world · 2 pts · 1y
python
I didn't realize it was december until this afternoon. I've generally chosen a new or spartan lang to challenge myself, but I'm going easy mode this year with python and just focusing on meeting the requirement.
::: spoiler solution
:::
morrowind@lemmy.ml · 2 pts · 1y
Smalltalk
grrgyle@slrpnk.net · 1 pts · 1y
TypeScript
This is for part #2 only.
Is it possible to get this more efficient? I would love a way that only required iterating over the list once, but I don't really have the focus to puzzle it out any less than
O(2n)(probably more than that, even, if you count reading in the data...).morrowind@lemmy.ml · 1 pts · 1y
Crystal
aurele@sh.itjust.works · 1 pts · 1y
Elixir
90s_hacker@reddthat.com · 1 pts · 1y
I've honestly forgotten how fucking cool the pipe operator is
Andy@programming.dev · 1 pts · 1y
Factor
https://github.com/AndydeCleyre/aoc-2024
rwdf@lemmy.world · 1 pts · 1y
Elixir
Total noob, but it's fun to learn.
LeixB@lemmy.world · 1 pts · 1y
Haskell
Euro@programming.dev · 1 pts · 1y
Viml
I think viml is a very fun language, i like weird languages lol, so this year im doing it in viml while trying to use as many of the original ed/ex commands as i can (:d, :p, :a, :g, ...)
::: spoiler Part 1
:::
::: spoiler Part 2
:::
sjmulder@lemmy.sdf.org · 1 pts · 1y
JavaScript
After writing a procedural to-the-point version in C, tried a JavaScript solution too because it's just perfect for list comprehension. The part 2 search is inefficient but the data size is small.
::: spoiler Code
:::
https://github.com/sjmulder/aoc/blob/master/2024/js/day01.js
VegOwOtenks@lemmy.world · 1 pts · 1y
Python
Lost a minute because I forgot about
abs.-.hosaka@programming.dev · 1 pts · 1y
Zig
SteveDinn@lemmy.ca · 1 pts · 1y
C#
Paradox42@programming.dev · 1 pts · 1y
Lua
Combined Solution
sleeplessone@lemmy.ml · 1 pts · 1y
Rust
I'm doing it in Rust again this year. I stopped keeping up with it after day 3 last year, so let's hope I last longer this time around.
::: spoiler Solution Spoiler Alert
:::
I'm keeping my solutions up on GitHub.
Quant@programming.dev · 1 pts · 1y
Uiua
Decided to try and use Uiua for each day this year. At least I'm not the only one to get this idea ^^
Run with example input here