I’m going throught Near-Palindromes puzzle but it kind of hard to understand what is a Near-Palindromes exactly. Furthermore tests doesn’t help a lot because there are too many words and it’s impossible to know on which ones our algorithme fails.
Anyone can provide a clear explanation of what is a near palindrome ?
I was thinking to levenshtein length between the two half of a word but it doesn’t work…
I am also having a problem with this puzzle.
The ‘expected’ result is illogical.
Test case: Multiple words
My output: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000001100000000010000000010010100000000000000000000000000000000000000000000010000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000010000000000100000000000000000000000000000000000000000001
It is wrong in 0-indexed positions 266 (false positive) and 422 (false negative).
At a cursory glance, I don’t see the string “1 four zeros 11” in the expected output string at all, so this is indeed a likely bug of the comparing program. (ping CG staff)
Yours doesn’t look so similar to Lupilum’s if you scratch the surface. The judge output is worthless in both of your cases. I wrote those tests, let me break the news first hand: a backslash or a null byte is not part of them.
But in his case we were able to compare the results anway by taking the 0s and 1s from the output pane and from the test list’s expected output, and compare them outside of the website.
Thanks JBM. Sad that I can’t tell which 0s and 1s are incorrect by comparing my 0s and 1s and the expected 0s and 1s. Now I have to scan 850 words in test 5 manually…
In test #5, for instance, you can see clearly that the third word “ada” is supposed to be recognized as a near-palindrome.
I would say that qualifies as “zero letters away” from a palindrome in my book.
It would be nice to say more explicitely in the problem definition that palindromes qualify as near-palindromes. That would avoid some head scratching for those who designed an algorithm that carefully avoids recognizing palindromes
well, I wrote more complicated code just to make sure you needed exactly one change to reach a palindrome, but I suppose that was just one way to read the rules.
Any palindrome is a near-palindrome, i.e. exactly one letter away from a palindrome: if it is of odd size, double (or change, or delete) the central letter; if it is of even size, add anything as central letter (or delete one of the two current central letters). There is no need to mention/clarify that in the statement as the problem solver is supposed to figure that out by himself I guess.
According to eggheads “a d-near-palindrome is a string of Hamming distance at most d from its reverse” so this official defintion indeed implies a palindrome is a d-near-palindrome for every d in [0, +inf[, and the problem asks to detect 1-near-palindromes, hereby called “near-palindrome” for brevity.
For mundane users, this might sound like saying a hit is considered a near miss though
FWIW, I wasn’t aware of “d-near palindromes” at time of problem setting, so calling them near-palindromes “for brevity” fits, but is historically inaccurate.
To be completely fair, this puzzle was set in a rush for other reasons.