93 lines
5.8 KiB
Plaintext
93 lines
5.8 KiB
Plaintext
|
|
Episode: 4007
|
||
|
|
Title: HPR4007: Advent of code day 1-5 catchup
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr4007/hpr4007.mp3
|
||
|
|
Transcribed: 2025-10-25 18:32:22
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is Hacker Public Radio Episode 4,074 for Tuesday the 12th of December 2023.
|
||
|
|
Today's show is entitled, Advent of Code Day 1-5 Catch-Up.
|
||
|
|
It is hosted by Daniel Person, and is about seven minutes long.
|
||
|
|
It carries a clean flag.
|
||
|
|
The summary is I talk through the first five challenges of this year's advent of code.
|
||
|
|
Hello Hacker's, and we are at that time of the year again.
|
||
|
|
We are at Advent of Code, and I've done the first five days of Advent of Code.
|
||
|
|
In this year, it has been a little bit interesting, a little bit controversial, and it's going
|
||
|
|
to have been a really good year.
|
||
|
|
So first, do you start off with Day 1, where we pretty much did some strings, read them
|
||
|
|
in, and then try to figure out where we could find numbers in the string, and we wanted
|
||
|
|
to find the first number and the last number in the string, and then add those together.
|
||
|
|
So it wasn't that hard, but there were still a bunch of people that didn't handle the
|
||
|
|
second part of this really well, because the first part was pretty simple, where you
|
||
|
|
just found numbers, but then the second part, they actually wrote the numbers out.
|
||
|
|
So there could be one written in out, O-N-E, in the text, and then you needed to parse
|
||
|
|
that as well, and replace it with a one, and they actually put two of them together.
|
||
|
|
So you had eight and two with just one T, which with eight W-O, where it's made it a little
|
||
|
|
bit complicated, how you actually needed to parse it, how you needed to actually think
|
||
|
|
about it, and so on.
|
||
|
|
But there were a lot of good examples, and got a lot of good solutions.
|
||
|
|
And then day two, we had the cube command room, pretty much a parse exercise.
|
||
|
|
You had a bunch of games where you draw a bunch of cubes from a bag, and then you needed
|
||
|
|
to figure out what's the least amount of different color cubes you had in the bag, and
|
||
|
|
what games you could play with the amount of cubes and so on.
|
||
|
|
So it was pretty simple as well.
|
||
|
|
Day three was a little bit more complicated.
|
||
|
|
You had a map with a bunch of numbers in it, and then you had a symbols close to these
|
||
|
|
numbers.
|
||
|
|
So first, you needed to figure out which had a symbol close to a number, and the next
|
||
|
|
roundup, you needed to figure out if a number were near a star, and if you had two, and
|
||
|
|
exactly two numbers near a star, then you needed to multiply them.
|
||
|
|
And that was the way of finding out the solution.
|
||
|
|
I found a solution that I'm pretty sure is incorrect, but I got the right number.
|
||
|
|
So I was not satisfied with date three at all, but it was at least a solution.
|
||
|
|
Today for scratch cards, we had a bunch of cards, and the cards had a bunch of winning
|
||
|
|
numbers, and a bunch of numbers that you actually had on your card.
|
||
|
|
So you had to figure out how many wins you had per your card.
|
||
|
|
And the second part was pretty much that you found the number of cards that you won,
|
||
|
|
and that in turn gave you new cards of the next coming up.
|
||
|
|
So for instance, if you have four wins on the first card, the second, third, fourth and
|
||
|
|
fifth was copied, and then you needed to figure out how many cards you actually got until
|
||
|
|
the copies ran out.
|
||
|
|
So a little bit more complicated, but still pretty simple.
|
||
|
|
A five on the other hand, now we are talking complicated.
|
||
|
|
So we had a bunch of seeds, and then we had maps that mapped from seed to soil, soil to
|
||
|
|
fertilizer, fertilizer to water, water to light, light to temperature, temperature to humidity,
|
||
|
|
humidity to location.
|
||
|
|
And each of these different maps were ranges, and if something fell outside of these ranges,
|
||
|
|
then you could do a one-to-one map between numbers.
|
||
|
|
So each seed were a particular number, and then you had a bunch of maps between different
|
||
|
|
numbers in a list.
|
||
|
|
So I created some kind of converter that's convert from one number to another number.
|
||
|
|
Then when we actually had ran it through and said, they seed, they seed, they seed.
|
||
|
|
And so on, we got the information that, no, no, no, these are not seeds.
|
||
|
|
These are two numbers where the first number are the seed, and the second number is the
|
||
|
|
range that you need to look in.
|
||
|
|
So the length of the number of seeds.
|
||
|
|
So if you start the number of 79, for instance, and then you had 14 numbers, then you had to count
|
||
|
|
up 79, 80, 81, and so on.
|
||
|
|
And in the large example, one of these seed ranges was so long it didn't complete on my
|
||
|
|
computer, but the great thing is that I put it in and ran it on 10 threads in my machines,
|
||
|
|
and because there were 10 different seed ranges, nine of them were completed in a reasonable
|
||
|
|
time, and one of those had the smallest location number, which was what we were looking for.
|
||
|
|
So I, one of the actual ranges I never completed, but I still got the right value.
|
||
|
|
Some that have commented on my videos said that this was not a good solution.
|
||
|
|
There is a solution where you can actually create a map from seed to location, and take
|
||
|
|
the values a lot less computation, and therefore that is the right solution.
|
||
|
|
I say, if you get a value, that's the right solution.
|
||
|
|
If you want to brute forces, you do it.
|
||
|
|
So however you want to solve these and whatever is the fun way to do this, that's the right
|
||
|
|
solution for me.
|
||
|
|
So these were the first five days.
|
||
|
|
I may be doing another catch-up after day 10, we'll see, and I hope that you found this
|
||
|
|
interesting.
|
||
|
|
Maybe you want to try out this, challenge yourself.
|
||
|
|
We are all available at adventofcode.com, and I really hope to see you in the next recording.
|
||
|
|
You have been listening to Hacker Public Radio at HackerPublicRadio.org.
|
||
|
|
Today's show was contributed by a HBR listener like yourself.
|
||
|
|
If you ever thought of recording podcasts, then click on our contribute link to find out
|
||
|
|
how easy it really is.
|
||
|
|
The hosting for HBR has been kindly provided by an honesthost.com, the Internet Archive
|
||
|
|
and our things.net.
|
||
|
|
On the Sadois status, today's show is released under Creative Commons, Attribution 4.0 International
|
||
|
|
License.
|