My solution to day 2 of 2024 Advent of Code in Unreal blueprints



An unofficial home for the advent of code community on programming.dev!
Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.
AoC 2024
Solution Threads
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | [14](https://pro |
-
Advent Of Code @programming.dev andioop @programming.dev Appreciation for Advent of Code
I know I'm not going to be a leaderboard type, especially given my schedule around the holiday seasons. So I take my time and read the whole problem, including the flavor text, and I have to say I appreciate it! Nice and festive, it's the little things that make this seem more like a fun programming puzzle exercise I actively want to do as recreation, and less like a dry exercise to force myself to learn a new language or library. But it still facilitates me doing those two things anyways. The flavor text, along with the ASCII art that gets colored in each day I star, helps it feel like a festive thing too—so I don't feel like I'm being a Grinch doing these puzzles during the holiday season.
I also appreciate the problems staying up after Advent for people using them off-season ;)
-
Advent Of Code @programming.dev somegeek @programming.dev why should we sort 2024-day1 ?
Hi guys.
I just did day1 of 2024 (I know, I'm late) this might be a dumb question but I reallydont understand why we should sort the two lists before substracting? I created some test cases with 10-20 items and calculated them manually, if you don't sort the list and just add all list1 items and substract from the sum of list2, you get the same answer. But it doesn't work with the large input file.
Let's say list1 has elements (a,b,c,d) and list2 has (e,f,g,h).
(a-e)+(b-f)+(c-g)+(d-h) = a-e+b-f+c-g+d-h = (a+b+c+d)-(e+f+g+h)
So the sorting shouldn't matter. Right? But it does. Am I too bad at basic math?
-
Advent Of Code @programming.dev Acters @lemmy.world my face when I use binary search to find the roots of a quadratic equation
hi I know this is a year old, but I solved it and used a custom implementation of binary search to solve this.
interestingly enough, in python at least, it is almost as performant as the quadratic equation for solving this lol (43.7 microseconds vs 64.9 microseconds) but now that I realized it is a simple parabola, you can just get the maximum after getting the minimum time and practically matches the quadratic equation performance. lol I know the math is faster as search space grows but I still think its interesting how performant this was.TLDR: I'm so data structures and programming pilled that I forgot basic algebra.
::: spoiler code
py
from os.path import dirname,realpath,join def profiler(method): from time import perf_counter_ns def wrapper_method(*args: any, **kwargs: any) -> any: start_time = perf_counter_ns() ret = method(*args, **kwargs) stop_time = perf_counter_ns() - start_time time_len = min(9, ((len(str(stop_time))-1)//3)
-
Advent Of Code @programming.dev Vulwsztyn @programming.dev Solution in Unreal Engine blueprints (and prolog)
vulwsztyn.github.io Advent of Code 2024 day 2 in Unreal blueprints & Prolog - Artur Mostowski -
Advent Of Code @programming.dev abbadon420 @programming.dev I'm looking for a list of all the puzzles and which programming topics they teach, does anyone know of such a list? Or else, can anyone offer a complete repository of python implementations?
I'm looking for something like this (these are not correct, just an example for what I'm looking for):
- 2021 - day 1: Dijkstra Algorithm
- 2021 - day 2: Dynamic Programming
- 2021 - day 3: Time efficiency, Hash tables
- etc
If there is no such thing, does anyone have a (fairly) complete (github) repository of python implementations from which I can build such a list myself? I would make all the puzzles myself, but I'm not that fast, I'm currently still on day 15 of 2024.
-
Advent Of Code @programming.dev CameronDev @programming.dev Visualisation Megathread
Visualizations are hard, and take time, so here is a thread to highlight the visualizations that we have found/created.
Please feel free to post your visualisations!
-
Advent Of Code @programming.dev CameronDev @programming.dev Final Leaderboard
Those of you running behind, keep at it, but this is the leaderboard as it stands at the end of 2024.
Happy new year!
-
Advent Of Code @programming.dev whoareu @lemmy.ca need help with day 7 part 1 of adventofcode
Hello,
I am trying to solve the day 7 using Rust and this is what I came up with so far:
undefined
use std::fs; fn calculate(answer: &i32, numbers: &mut Vec<i32>) -> bool { if numbers.len() >= 2 { let tmp1 = numbers[0]; let tmp2 = numbers[1]; numbers.remove(0); numbers.remove(0); numbers.insert(0, tmp1 * tmp2); if calculate(answer, numbers) == true { return true; } else { numbers.remove(0); numbers.insert(0, tmp1 + tmp2); if calculate(answer, numbers) == true { return true; } else { return false; } } } else { if *answer == numbers[0] { println!("> {} true", numbers[0]); return true; } else { println!("> {} false", numbers[0]); return false; } } } fn main() { let contents = fs::read_to_string("sample.txt") .expect("Should have been able to read the file"); for line in contents.lines() { let tmp = line.split(":").collect::<Vec<&str>>(); let answer = tmp[0].to_string().parse::<i32>().unwrap();
-
Advent Of Code @programming.dev CameronDev @programming.dev Using LLMs to solve AOC
www.jerpint.io Performance of LLMs on Advent of code 2024Taking a look at how LLMs performed on the latest AoC competition.
A lot lower success rate than I suspected, I guess a lot of the scoreboard times were probably legit?
-
Advent Of Code @programming.dev Gobbel2000 @programming.dev What were your favorite puzzles of 2024?
Now that Advent of Code 2024 has concluded, I wanted to get people's opinion on what puzzles they especially liked looking back. This could be because of the puzzle mechanics, the description, because you are especially proud of your solution that day, or for any other reason.
Feel free to answer even if you only saw part of the puzzles.
My picks would be:
- 14 (Restroom Redoubt, robots moving into christmas tree shape). Even though it caught me off-guard in the moment, I did like that part 2 had this very imprecise requirement for once. Definitely made for varied, creative solutions.
- 15 (Warehouse Woes, robots pushing boxes) The second part was a fairly big complexity spike with just a minor change in the tasks. Basically a form of simulation where the hard part is finding a good data representation for the setup. I liked this one because debugging was such a visual process for me, by printing the grids.
- 17 (Chronospatial Computer, running a machine code) For me the first reall
-
Advent Of Code @programming.dev CameronDev @programming.dev Preliminary Leaderboard
Well, that was a month. Congrats everyone who has reached the end, and thanks to everyone who has contributed solutions and advice.
Sometime in January I will create a megathread for visualizations. If anyone has any other ideas, happy to hear them, otherwise, take a well earned 11 month rest until next year :D
-
Advent Of Code @programming.dev sjmulder @lemmy.sdf.org Here's a writeup of my experience this year! It's been a lot of fun, especially hanging out with people here and on Mastodon. Thanks everyone, and Eric in particular!
-
Advent Of Code @programming.dev CameronDev @programming.dev 🎄 - 2024 DAY 25 SOLUTIONS -🎄
Day 25: Code Chronicle
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://topaz.github.io/paste/ 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/6637268
- 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
-
Advent Of Code @programming.dev CameronDev @programming.dev - Pt2 - Manual Inspection?
I am wondering if manual inspection is the way to go for pt2? Seems almost achievable with some formatting. Anyone been down this road?
-
Advent Of Code @programming.dev CameronDev @programming.dev 🤖 - 2024 DAY 24 SOLUTIONS - 🤖
Day 24: Crossed Wires
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://topaz.github.io/paste/ 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/6637268
- 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
-
Advent Of Code @programming.dev CameronDev @programming.dev 💻 - 2024 DAY 23 SOLUTIONS -💻
Day 23: LAN Party
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://topaz.github.io/paste/ 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/6637268
- 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
-
Advent Of Code @programming.dev CameronDev @programming.dev 🐒 - 2024 DAY 22 SOLUTIONS - 🐒
Day 22: Monkey Market
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://topaz.github.io/paste/ 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/6637268
- 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