top | item 38487055

(no title)

randomifcpfan | 2 years ago

The potential for overlapping numbers was the thing that tripped up many developers. But a simple “find the first number searching from each end, just like the puzzle instructions asked” implementation just worked.

The lesson is to read the puzzle instructions carefully and avoid solving more general problems.

discuss

order

berkes|2 years ago

I did not use regexes, so as said, the most common edge case did not hit me.

What hit me was stupid, but also not covered in the example. It was rather implied and obvious from the example, though.

SPOILER ALERT

In my mistaken implementation `one2three1` would find "1, 2, 3" but not the second case of 1. Now, while the description never explicitly mentioned this, it's still obvious that it should be "11" and not `13`. Though my example, derived by TDD-ing from the example, gave `11`.

Only after I diffed my output with that of a known working solution did I find a few lines (there were several of them, though not that much) that made my issue clear: I missed the second case of a number appearing. So "one1one1one" in my solution would only find the first one.

codr7|2 years ago

Same here, I also didn't use the replace-strategy nor regexes.

b3orn|2 years ago

This is what I did and then was confused why everyone else I talked to thought it was a hard problem.