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?
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)
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.
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](https://i.rdrama.net/i/l.webp)
Jump in the discussion.
No email address required.
thank you![:marseyexcited: :marseyexcited:](https://i.rdrama.net/e/marseyexcited.webp)
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
wtf is a fold
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
and fold with default value is called
reduce
which sounds more like something recognisableJump in the discussion.
No email address required.
Yeah that's exactly what javascript reduce does
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Short for "femaloid".
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
I wasted a lot of time because first I stored the numbers and symbols in a stupid way, and my first "solution" worked on the small example they gave but not on the data on the big file, there were some weird edge cases I didn't count, but I managed to overcome it and finally store symbols and numbers separately, and the second task ended up being much easier
Jump in the discussion.
No email address required.
More options
Context
This took me so long
Luckily part two was a simple change
Jump in the discussion.
No email address required.
More options
Context
The edge case of a number being at the end of each line, annoyed for wait to long, eventually just added an additional dot to every line
Jump in the discussion.
No email address required.
More options
Context
Difficulty progression seems about the same as last year. I think a lot of people thought it might be harder this year after day 1.
Jump in the discussion.
No email address required.
More options
Context
I had to parse the digits
by hand because I couldn't get the findBounds to work in Nim :/.
Step 1: I drew a 3x3 square
around every symbol, then for every number I checked if it was within a square.
Step 2: I drew a rect around every number, then for every symbol
I checked if it was within two rects.
Jump in the discussion.
No email address required.
Solving problems with NES collision detection algorithm![:marseycopter: :marseycopter:](https://i.rdrama.net/e/marseycopter.webp)
Jump in the discussion.
No email address required.
More options
Context
Tried to improve on this, but I couldn't really get anywhere. (77 lines total)
This time, I'm using
parseUInt
fromparseutils
.strutils
throws when it finds an invalid character,parseutils
simply returns what it found.Jump in the discussion.
No email address required.
Man you are fricking crazy!
I love that you keep it linear and just add or subtract an entire row to go to the same point one line below or above, took me forever to figure out. Also didn't know you could do ranges over chars, that's neat. Also had no idea there was a "result" variable defined automatically for all procs.
I don't know if you know and prefer the str.len-1 way, but you can index iterables with [^1], [^2], ... to get items from the end.
You could also do this for the mask, that way you don't need the comments or the superfluous items to keep the indexing right:
Though I guess it's a matter of style.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context