Mac@programming.dev to Advent Of Code@programming.dev · 2 年前[2023 Day #1] Massive Difficulty Increaseprogramming.devimagemessage-square25linkfedilinkarrow-up1141arrow-down16
arrow-up1135arrow-down1image[2023 Day #1] Massive Difficulty Increaseprogramming.devMac@programming.dev to Advent Of Code@programming.dev · 2 年前message-square25linkfedilink
minus-squareStrawberry@lemmy.blahaj.zonelinkfedilinkarrow-up1arrow-down2·edit-22 年前Just don’t replace, or replace only the first letter with the numeral
minus-squareDaleGribble88@programming.devlinkfedilinkEnglisharrow-up1·2 年前You can’t just replace the first letter either, because depending on the order of your replacements, you could be replacing the end of another number. (Encountered this exact problem trying to optimize my solution.)
minus-squareCameronDev@programming.devMlinkfedilinkarrow-up4·2 年前I replaced the second letter, none of them overlap 2 letters.
minus-squareStrawberry@lemmy.blahaj.zonelinkfedilinkarrow-up2arrow-down1·2 年前As long as you replace any spelled out numbers from left to right it should work
minus-squarestifle867@programming.devlinkfedilinkarrow-up1·2 年前2oneight - if you replace from left to right you get 21ight or 21. This doesn’t work for part 2 as the answer should br 28.
minus-squareStrawberry@lemmy.blahaj.zonelinkfedilinkarrow-up2arrow-down1·2 年前We’re talking about just the first letter, so 2oneight —> 21neight —> 21n8ight
Just don’t replace, or replace only the first letter with the numeral
You can’t just replace the first letter either, because depending on the order of your replacements, you could be replacing the end of another number. (Encountered this exact problem trying to optimize my solution.)
I replaced the second letter, none of them overlap 2 letters.
Clever
As long as you replace any spelled out numbers from left to right it should work
2oneight- if you replace from left to right you get21ightor21. This doesn’t work for part 2 as the answer should br28.We’re talking about just the first letter, so
2oneight—>21neight—>21n8ight