Algorithms + Data Structures = Programs - Episode 268: Advent of Code 2025 (Day 6)

Episode Date: January 9, 2026

In this episode, Conor and Ben chat about Advent of Code 2025 Day 6!Link to Episode 268 on WebsiteDiscuss this episode, leave a comment, or ask a question (on GitHub)SocialsADSP: The Podcast: TwitterC...onor Hoekstra: LinkTree / BioBen Deane: Twitter | BlueSkyShow NotesDate Recorded: 2025-12-22Date Released: 2026-01-09Advent of Code 2025Day 6 ProblemBen's Day 6 AoC 2025 in PythonConor's Day 6 AoC 2025 in BQNtranspose Hoogle TranslateIntro Song InfoMiss You by Sarah Jansen https://soundcloud.com/sarahjansenmusicCreative Commons — Attribution 3.0 Unported — CC BY 3.0Free Download / Stream: http://bit.ly/l-miss-youMusic promoted by Audio Library https://youtu.be/iYYxnasvfx8

Transcript
Discussion (0)
Starting point is 00:00:00 Actually, it might put the operation at the back. So you might need to do a one rotate after you, uh, look at that. Everybody loves a rotate. And also, too, you need the splitting functions, which I have in a string library. And actually, I borrow the names of words and unwords from Haskell. Though a major difference is that I'm evaluating a... You're evaluating a string. You're doing a reduction on the integers.
Starting point is 00:00:22 Yeah, yeah. Very nice, though. Still like 90% the same. Yeah, exactly. Welcome to ADSP, the podcast. episode 268 recorded on December 22nd, 2025. My name is Connor, and today with my co-host, Ben, we chat about advent of code 2025 in C++ and BQN, day six.
Starting point is 00:00:58 You should try day six. I recommend that you in particular should try day six as an array language programmer. So day six, it's funny. I don't know at what point, but I was kind of sad. I was kind of sad at some point in the last couple of weeks because I had given up so quickly. And I was like, oh, you know, having a code. I might have been on a plane or something. And I was just like, you know, maybe I should go look.
Starting point is 00:01:20 And the first thing I was looking for was to see, was there a huge drop off after day three? I was hoping for my biases to be confirmed in that like they really messed up with day three. And that it just, you know, half as many people on day four were doing it. That was not the case. But then I went to look at was there a day that was easier. Because in years past every once in a while, they have like a day five or six or seven. and you're like, oh, this is much easier if you know the technique or whatever. Right.
Starting point is 00:01:50 Well, and the difficulty is definitely not linear, right? Erica said this. Sometimes he throws in an early one, which is quite difficult. Yes. And quite often, a later one will build on what came before. Interestingly, there's often also a sort of cellular automata thing going on. They're quite common for advent of code puzzles. And I think Day 4 was sort of like, yeah, day 4 was sort of like that,
Starting point is 00:02:12 but there wasn't the later one which built on it. Anyway, carry on. What were you going to say about day six? Well, no, I was going to say. So day six was the day that I had cherry picked. I didn't actually go and solve it, but I did think to myself, at least for Part A. I'm curious if you can tell me what Part B is, but Part A could be solved very, very cutely
Starting point is 00:02:31 by basically just like transposing the matrix and then you have a value-primitive basically in all array languages where if you just construct a string that is a valid program, you can just execute it. So all you would need to do is insert a slash after the operation, which would be pretty easy, right? The binary operator. Well, I guess we should explain the problem if we're going to chat about this a bit. Do you want to explain it? Because you're the one that actually did it. I was just looking at it and not paying attention to what you said for the last 30 seconds.
Starting point is 00:03:02 Sorry. So go, why don't you go ahead and explain? Yeah, I put the cart in front of the horse once again for like the sixth time in this conversation because I started explaining how you solve it without even mentioning anything about the problem. So you're going to say something though. But you're right. Like day six, if you have transpose, transpose is a big workhorse for day six. Big work course. Yeah.
Starting point is 00:03:24 And I learned transpose in Python. Oh, yeah, yeah. The Star Star, Splat, whatever. Zip of Star. Yeah, yeah. Yeah. Actually, I looked on Google Translate. Oh, did you?
Starting point is 00:03:37 Because I was going to say it. I'm pretty sure I was literally just to bring it up. I don't know if it's there. I think it is. Maybe it is. I didn't know you want to search for. If you type transpose and then you, uh, uh, oh no, it's not. Interesting.
Starting point is 00:03:51 Python's. Oh, actually, wait. If I go show expressions, there it is. It's hidden. Here, let me share my screen for a set. Oh, okay. We'll share window next time. Maybe I'll tweet this out.
Starting point is 00:04:05 Um, so if the default is turned. on that's kind of a it's kind of evil of me so you go to if you search transpose on who will translate a website I built except if you spell it correctly it brings up by default every function that matches that textual name but if you click on any and you can see that all of these have the exact same semantics because they're all the same color if you click on one of these now it'll show all of the functions across languages regardless of the name that match the semantics and D calls it transposed.
Starting point is 00:04:40 Moon, which is esoteric language made by an individual that wanted to add it, calls it Zip, and Q calls it Flip. So I thought for sure I added this, but that's because I decided to hide expressions and
Starting point is 00:04:55 third-party libraries. Oh, okay. The ZipStar is not actually a function, but it's an expression. And so if you do that, ZipStar, sure enough, is the very last thing at the bottom from Python. Because when you said that, I was like, I'm pretty sure I added that to Google Translate. However, it is hidden. Okay. Makes sense. But I didn't see it. Right. Because star is, of course, just for people
Starting point is 00:05:18 who don't know Python, star is kind of the destructuring operator, right, which sort of takes the list to a pack of elements, if you like. And then, so if you have a list of lists and you say star of it, you get the pack of lists and then you zip them. And, of course, that gives you, you the first one of each, followed by the second one of each. So it's transpose. It's a magical incantation that somehow maps to transpose. But yes, day six, so it gives you a table of numbers that are spaced delimited. And at the bottom of each column is a binary operation, either multiply or plus. So the asterix or the plus sign. And it basically just asks you to, based on that binary operation, compute the reduction.
Starting point is 00:06:07 of that column and return the sum of all those values. And so in BQN, a plus or multiply reduction is literally just, I guess you would have to replace the asteris with the multiplication symbol. I didn't realize that. But you could just add a slash to each of those things and then that becomes a reduction. And if you transpose it and I guess maybe transposing this, no, yeah, it will put the, actually it might put the operation at the back.
Starting point is 00:06:39 So you might need to do a one rotate after you, look at that. Everybody loves a rotate. And also, too, you need the splitting functions, which I have in a string library. And actually, I borrow the names of words and unwords from Haskell because they're so nice and so useful. But you could basically do a words on each line,
Starting point is 00:06:59 put that in a matrix. And it has to be strings at that point because you've got your operation. Do a one rotate on that, or do a transpose, then a one rotate that gets your binary operations at the beginning. And then replace the a a asterisk with a multiplication, add a slash, do an unwords on each row of your matrix now that turns it back into a valid BQN expression in the form of a string. And then just call the system BQN function, which is effectively an evaluate. And anyway, so I did look at this and I solved it in my head. I didn't actually solve it.
Starting point is 00:07:33 But then I was very curious, not curious enough to actually write the solution to what is part B and is it as nice to solve as part A? So I did the same as you just outlined, except in Python. The one rotate, the transpose, and then I take the head and the tail. So after the one rotate, the head is the operator and the tail is the reduction list. And then I just use the operator string to look up into a array of two functions plus and multiply. And then do you have like an eval function in Python or? No, no, because, sorry, it's a map lookup. It's a dictionary, right?
Starting point is 00:08:13 So star is the function, operator.comole. Yeah. Right? And plus is operator. And then you just reduce using that operation across the list. Using like the funk tools reduce? Yes. And then just turning like each string into an int?
Starting point is 00:08:30 Each string. Yeah, each string's already an int. Yeah, sorry. No, I map, I map in to cross the string, across the list, across the tail of the list. The major difference is that I'm evaluating a... You're evaluating a string. You're doing a reduction on the integers. Yeah, yeah.
Starting point is 00:08:47 Very nice, though. Still, like, 90% the same. Yeah, exactly. And then what was part B? So I don't actually, this is a surprise for me, because I never did part A, actually. I just, like I said, solved it in my head. Right. Well, now you can code up part A in, you know, five minutes.
Starting point is 00:09:01 part B is like part A but more tricky transposing because it turns out that not only are the so the matrix itself in part A was transposed in part B the I don't think I'm going to be able to explain this exactly but the numbers are within the column have to be read column-wise instead of row-wise if you're like so so you've got if you've got a sum of like three-three-digit numbers.
Starting point is 00:09:33 Then instead of being those three-digit numbers, they are the column-wise three-digit numbers. Right. So, I mean, in the first column of the example, the numbers are 1-2-3, 123 on the first line, 45 on the second line, and 6 on the third line. So if you transpose that, the numbers are now going to be 356, 24, and 1,
Starting point is 00:09:51 something like that? Yes. Yeah. What if, are you guaranteed that you have contiguous stretches? Or are there, is there potentially like a three-digit number followed by a one digit number, followed by a three digit number. They can change in their length, yes. You have to take account of, you have to sort of read them in at some point as columns,
Starting point is 00:10:13 because each column of numbers is delimited by a column of spaces. But within a column, the numbers can be either left justified or right justified. They can be three digit, two digits, one digit, that sort of thing. If you have a gap in between, you know, two digits, do those just get compacted So basically, so if you have in a given column, no, those stay as separate numbers. And the number has to stay in its right, in its correct justification in the column. Right. In order to treat each digit as its correct place value in the transposed numbers.
Starting point is 00:10:47 So there's a little bit of jiggery pokery around that. Well, I mean, that makes it much more tricky. Because if you can just split. Yes, and that's the tricky part. You can't just split them and collapse all the spaces into one space. Yeah. If you do your Haskell words, you know, put them in a column and then kind of reconstruct the numbers. You know, that's actually not too tricky. But if you need to keep the alignments respective of where the spaces are, that is now you need to like take a knife and cut out your numbers and keep them that way. That is much less trivial. But interesting, nonetheless. How did you do that one? Very similarly to the first one, except with the input processing slightly different. Let's see.
Starting point is 00:11:34 I postponed the split, like we were just saying. So I read the input line by line. And for the first star, I just go ahead and split the lines at that point. For the second star, what did I do? I had to figure out, yeah, I have to figure out where the spaces line up. Right. Well, I mean, are we, is it given that because by the example, if we just look at the binary operations, it looks like one before the next binary operation is the, is that, is that the case? So if you transpose the whole thing for the second part, then you turn columns of spaces into rows of spaces. And they're much easier to detect. That's a nice little trick. That's what I did.
Starting point is 00:12:20 Very cute. So then you, then you know, then you sort of automatically. So taking a row of spaces is just all off, right? So much easier than the commoner spaces. So once you've transposed, then you effectively get the blocks of numbers for free, and then you can do your further transposition and whatever it is. Very neat. I will say, a much more fun, nicer problem than day three,
Starting point is 00:12:45 unless if you're in C++ plus and when you have max element. In that case, maybe day three is nicer. I can send you my... I solve day six in Python. and there's the solution. Yeah, it's pretty nice. I mean, I would have done import operator as op in order to save yourself six characters there.
Starting point is 00:13:02 Sure. Yeah, you can see on line 32, where I detect the rows of spaces. I mean, that's a perfect spot for an array language reduction. Space equals not all. Is there a... So that's actually my... I wrote chunk as a generator. As you can see.
Starting point is 00:13:31 So I'm yielding each chunk. Oh, I see, I see. So that predicate is basically when the chunk ends, which is when the... That predicate is true while the chunk is still going. And then as soon as that predicate fails, you're on a row of spaces and it's time to start the next chunk. Yeah.
Starting point is 00:13:48 Well, maybe before this gets released, I'll code up a BQN version. for folks to see the comparison. All right, well, we're 30 minutes past. We knew this was going to happen. And I still feel like we've probably got a ton of stuff that we could have chatted about. We'll have to save it for another time.
Starting point is 00:14:08 Yeah, I mean, happy holidays, not just to you, but everybody listening. Likewise. At this point, actually, now, I don't know, maybe it's the new year, and this is part two or something of this. Because I'm not going to drop a two-hour podcast. This will be happy. Happy New Year to.
Starting point is 00:14:23 January 15th or whatever it is. Yeah, yeah, yeah. Well, hopefully, I don't know how I'm going to dice it up, but I think I'll release an hour episode this Friday, but then so it'll probably be cut into three. How I'm going to do that, I'm not exactly sure. But, yeah, it's been good to catch up. Yeah.
Starting point is 00:14:43 Do you have plans in 26 yet to conference attend? Or that's a down-the-road decision? It's a down-the-road decision. I suspect I won't be traveling a whole lot. Oh, right, yes. So my plan, my default plan is probably C++ now and CPCOM. Okay. All right.
Starting point is 00:15:05 Well, we will, if not at a conference, we will, at minimum, get the chat online. Yes. Hopefully we will cross paths at some point. Hope so. Be sure to check these show notes, either in your podcast app or at ADSP thepodcast.com for links to anything we mentioned in today's episode, as well as a link to a get-up discussion where you can. you can leave thoughts, comments, and questions. Thanks for listening. We hope you enjoyed
Starting point is 00:15:26 and have a great day. I am the anti-brice.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.