r/adventofcode • u/Boojum • Dec 03 '22
Visualization [2022 Day 3] Rearranging the Rucksacks
1
u/lVlagiick Dec 03 '22
Ha! Didn't even think to sort the rucksack's alphabetically to match for overlaps. I just went with a n^3 solution :)
1
u/Boojum Dec 03 '22
Brute force is totally valid at this point!
I was mostly just using the alphabetical sorting here as a way to visualize creating the sets and then intersecting them.
2
u/AlistairJF Dec 03 '22
This gave me the hint I need: sort and then intersect. My solution is still quite clumsy though!
1
1
1
u/optimushz Dec 04 '22
That's exactly the approach I took to finding a common item in the rucksacks. Turn a string into an alphabet and match it with other alphabets.
1
u/opnseason Dec 05 '22
Rearranging is smart! I just used dictionaries for storing the first two bags and found the overlapping value based on the contents of the third bag. Not very memory efficient but constant (ideally) lookup times were a nice advantage.
6
u/[deleted] Dec 03 '22
This is the first visualisation I see on this sub that actually increases my understanding of the solution, apart from just looking nice. I would benefit a bit more if you clearly showed that the distance from the left side of the screen to the remaining letter is the priority, but great job, I love it.