[2023 Day 1] It is not supposed to ramp up this fast

3 years ago by morrowind to c/advent_of_code

silvanocerza 20 points 3 years ago

I was surprised seeing ton of people going for the replace approach. It didn't even cross my mind to edit the string, I went straight for regex for part 1 and it was easy enough to adapt it for part 2.

path: 0 5743643, hotness: undefined, score: 20, children: 2
UndercoverUlrikHD 4 points 3 years ago

On the surface level it makes sense since you already wrote the code to extract the numbers based on digits, which will be in the back of your mind. Once you have some time think about though, it's obvious it's better to just directly find the first and last "digit" without changing the string.

path: 0 5743643 5747903, hotness: undefined, score: 4, children: 0
stifle867 1 point 3 years ago

I did this exact thing and hit the point where it didn't work. I appreciated that the problem broke my code because it made me arrive at a better solution.

path: 0 5743643 5746981, hotness: undefined, score: 1, children: 0
dns 9 points 3 years ago

My solution was worse than most: replace one -> one1one You are only going to do the replace all for each number and if the "e" is also in eight it is still there for the next set of replace.

A better quick and dirty solution from Mastodon was to just add the common character first: twone -> twoone

path: 0 5743278, hotness: undefined, score: 9, children: 6
Lmaydev 4 points 3 years ago

I just check every substring haha

path: 0 5743278 5744171, hotness: undefined, score: 4, children: 0
abbadon420 3 points 3 years ago

That's an esthetic abomination, but very clever

path: 0 5743278 5745908, hotness: undefined, score: 3, children: 2
AnarchistArtificer 1 point 3 years ago

I have a friend who says that "whatever works is elegant" and solutions like OP's is why I simultaneously love and hate that phrase.

path: 0 5743278 5745908 5748327, hotness: undefined, score: 1, children: 1
sus 2 points 3 years ago

Behold, elegance:

digits = { "one": [1,2], "two": [2,2], "three": [3,4], "four": [4,3], "five": [5,3], "six": [6,2], "seven": [7,4], "eight": [8,4], "nine": [9,3], "1": [1,1], "2": [2,1], "3": [3,1], "4": [4,1], "5": [5,1], "6": [6,1], "7": [7,1], "8": [8,1], "9": [9,1] }

and what comes afterwards is even more elegant, for it works!

path: 0 5743278 5745908 5748327 5748947, hotness: undefined, score: 2, children: 0
Turun 2 points 3 years ago

The problem is that 21 is not the only problematic combination.

path: 0 5743278 5743503, hotness: undefined, score: 2, children: 0
damium 1 point 3 years ago

You can also use o1e as there are never more than a single shared character. It also doesn't change the string size so it can be done in place. Still an ugly hack of a solution.

path: 0 5743278 5750889, hotness: undefined, score: 1, children: 0
SigmarStern 7 points 3 years ago

I have hacked together the ugliest of solutions and got my two stars but at what price?

path: 0 5742261, hotness: undefined, score: 7, children: 3
superfes 11 points 3 years ago

I just reverse the string and reverse the number names >_>

Cheater?

Maybe...

path: 0 5742261 5742995, hotness: undefined, score: 11, children: 1
SigmarStern 3 points 3 years ago

That's clever. Way more than my Regex abomination

path: 0 5742261 5742995 5743336, hotness: undefined, score: 3, children: 0
cm0002 3 points 3 years ago

everything

path: 0 5742261 5742596, hotness: undefined, score: 3, children: 0
Bumblefumble 2 points 3 years ago

Just saw this community and it looks cool even though I'm probably not capable of solving most of the puzzles. But having looked through the community, I can only really find solution threads. Where are the actual puzzles posted so I can give it a go?

path: 0 5744591, hotness: undefined, score: 2, children: 5
dns 7 points 3 years ago path: 0 5744591 5744735, hotness: undefined, score: 7, children: 4
grue 3 points 3 years ago

But I don't wanna log in, though. I don't care about the leaderboards or anything like that, and call me old fashioned, but I don't like giving my identity to every little website I visit as a matter of general principles.

path: 0 5744591 5744735 5746253, hotness: undefined, score: 3, children: 3
JPAKx4 2 points 3 years ago

There is an anon mode, but it does want you to log in to keep track of progress, either through Google, GitHub etc. I do wish there was a true logless mode but I think it's cool enough for me to just want to do

path: 0 5744591 5744735 5746253 5749985, hotness: undefined, score: 2, children: 0
drugo 2 points 3 years ago
path: 0 5744591 5744735 5746253 5749379, hotness: undefined, score: 2, children: 1
Shareni 1 point 3 years ago

What, you didn't give them your social security number, passport, dental records, and three generations of birth certificates?

path: 0 5744591 5744735 5746253 5749379 5749803, hotness: undefined, score: 1, children: 0
advent_of_code
advent_of_code

@programming.dev

login for more options
1248
184
1

An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Everybody Codes is another collection of programming puzzles with seasonal events.

EC 2025

AoC 2025

Solution Threads

M T W T F S S
1 2 3 4 5 6 7
8 9 10 11 12

Visualisations Megathread

Rules/Guidelines

  • Follow the programming.dev instance rules
  • Keep all content related to advent of code in some way
  • If what youre posting relates to a day, put in brackets the year and then day number in front of the post title (e.g. [2024 Day 10])
  • When an event is running, keep solutions in the solution megathread to avoid the community getting spammed with posts

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

go to feed...