Unable to load image

Advent of Code day 3: you guys had ONE JOB edition

I get out of my certification exam and there's only one thread and they put the wrong day so the admins couldn't find it.

This is why we can't have anything nice. I'll just copy yesterday's OP

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

16
Jump in the discussion.

No email address required.

tripleposting my comment.... do you think you passed the exam?

First a hint: my input parser was broken because I forgot that a number could end at the end of the line

Here's my solution, the two functions left off are an ugly parser which spit out sets containing tuples (symbol, i, j) and (value, i, range[j]) and to_search(i,j) spits out adjacent squares (I did skip 0,0 but just 1-indexed instead of checking -ves, using max(x-1, 0. is kewl). If I was smarter I would've used a map/dict somehow, which would've made .contains() viable which might've been more performant, but having to search by symbol for p2 would negate that probably. On the bright side I'm learning to use iterators over loops which might help my ongoing transition to Rust programmer.

https://i.rdrama.net/images/17015920751163921.webp

Jump in the discussion.

No email address required.

pls post the ugly functions I wanna see it

Jump in the discussion.

No email address required.

late, but 4u https://i.rdrama.net/images/17016894359648337.webp

Jump in the discussion.

No email address required.

thank you :marseyexcited:

Jump in the discussion.

No email address required.

wtf is a fold


:!marseybooba:

Jump in the discussion.

No email address required.

The docs have an autie explanation with steps which might help - https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.fold

But I would just say that return nums.fold(1, |n, acc| n + acc)

would be a bit like

acc = 1
for n in nums {
   acc = n + acc
} 

return acc

and fold with default value is called reduce which sounds more like something recognisable

Jump in the discussion.

No email address required.

Yeah that's exactly what javascript reduce does

Jump in the discussion.

No email address required.

Short for "femaloid".

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.