dns@aussie.zonetoAdvent Of Code@programming.dev•[2023 Day 1] It is not supposed to ramp up this fast
0·
10 months agohttps://adventofcode.com/2023 The first question is public, login to get your test data and submit your answers and unlock part 2.
https://adventofcode.com/2023 The first question is public, login to get your test data and submit your answers and unlock part 2.
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
$3 or 2 for $5
The bug is some strings can have overlapping characters. onEight threEight fivEight. There are more cases. So if you do a search and replace your string becomes 1ight 3ight and the second number does not get found.
Possible fixes: Search and replace and add the extra letter: oneEigh then search and replace. Search and replace words to numbers but put some extra letters in just in case.