• Cyno@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    1 年前

    I’m stuck on one of these intricacies now! I saw some of the ideas on how other people did it but i honestly have no clue what i did wrong. Got any tricky examples to share?

    • abbadon420@lemm.ee
      link
      fedilink
      arrow-up
      2
      ·
      1 年前

      I just solved it. I printed every set of integers in the format “Result: [theTwoDigits], from string: [inputString]” and mannually checked all of them. Eventually found the edge case that was causing troubles. It was a typo.

      • Cyno@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        1 年前

        Oh god, sorry to hear that 😅i’m feeling desperate enough to try that, i just wrote a different implementation and i get the same (wrong) result. At this point I just want to know what i misunderstood or mistyped cuz its driving me crazy

        • dns@aussie.zone
          link
          fedilink
          arrow-up
          2
          ·
          1 年前

          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.

          • Cyno@programming.dev
            link
            fedilink
            arrow-up
            1
            ·
            1 年前

            Thanks, I managed to find the culprit in the end however - I was using a forward-look of 5 characters for finding if it matches a word so in a string of a3two for example, it would register the two before the 3. It was an easy fix once i found the issue.