Day 3: Gear Ratios | Advent of Code 2023

preview_player
Показать описание


00:00 Intro
00:28 Puzzle 1
07:39 Puzzle 2
10:49 Outtro
Рекомендации по теме
Комментарии
Автор

My method focused on finding then looking around each symbol, then adding the numbers around to a global sum (of course storing their start points in an array so we don't get the same one twice). It may have been worse, but I was very happy with the part 2 lol

colehdlr
Автор

With any language that has a group-by function part 2 becomes easy as hell. All I had to do was for each number basically save the number itself along with the location of its adjacent gear (after observing that every number only had 1 or no symbol adjacent to it) if it exists. Then group by this location into a map/hashmap, get the values, filter the ones where the amount of numbers is exactly 2, then multiply both numbers on each gear, add them up, profit.

kozmicluis
Автор

Great presentation. Thank you for being concise and clear with your structure.

blaise
Автор

Great solution. I made some complicated bs, this is so much better and easier to read.

NicolastheThird-hm
Автор

This is such a smart solution. Thank you!

dylansuther
Автор

I feel so dumb I did day 1, 2 but had no idea how to do this day. Had to cheat and look up the answer

bigupbig
Автор

I've created a point struct to store position of a character.

Then, I stored the number, the positions of its start and end characters. Then I pushed the info into an array.

I stored the position of the symbols also. Then did some coordinates calc to check if the numbers are in range of the symbol.

The part 2 was easy since I just changed the code to store only asterisk symbols and check the length of near numbers.

But I was thinking... It's still slow. I will use an array of buckets to improve near point search, checking only 3 lines for each symbol.

willzin-da-esfiha
Автор

I made a total mess of part two to the point where 'git reset --hard' was the best option. Got there eventually but not an elegant solution at all. The feeling amongst work colleagues is that the puzzles seem a bit harder this year. Let's see how it goes...

TheFrogfather
Автор

I came out with a very similar code.. but mine isn't working 😂. I'll try your code with my input. Thanks

DiegoCattaneo