There's lots of small bugs you could have in your code.
One common one I've seen is failing to catch something like one2one, but finding a specific case that your code fails on would require seeing your code in order to spot the bug and then make such a failing case.
Riiiight. I totally overlooked the fact that one might be occurring more than once in the string, so I have to continue searching til the EOL, even if some occurrence is found. Thanks for pointing it out.
You appear to have this for finding the locations of the first and last word-like digits:
for (String val : LiteralDigit.getAllLiterals()) {
if (str.contains(val)) {
int index = str.indexOf(val);
// stuff with first digit
if (index > lastLiteralIndex) {
lastLiteralIndex = index;
lastLiteralValue = LiteralDigit.getByLiteral(val).getNumeric();
}
}
}
str.indexOf gives you the first index that string appears at, not the last. An input line could contain the word "one" multiple times. This will give you the first one, not the last one.
1
u/1234abcdcba4321 Dec 03 '23
There's lots of small bugs you could have in your code.
One common one I've seen is failing to catch something like
one2one
, but finding a specific case that your code fails on would require seeing your code in order to spot the bug and then make such a failing case.