[Community Puzzle] Find the Replacement

https://www.codingame.com/training/medium/find-the-replacement

There is something hinky with either the validators or the test cases. My code does not pass validator 5 (Random, all different), but passes the test cases 100%.

If I don’t check for endless loops, my algorithm correctly identifies all of the changes the validator is looking for, then will just infinitely cycle between two letters.

Has anyone else seen this behavior.

Hello, validator 5 contains letters and uppercase letters. Like all other test cases, there exists a set of replacements A->B such that 1. A does not repeat, and 2. multiple replacements may point to B.

Due to the nature of the problem requiring the output to print found replacements in the same order as they are found (output specification), if the dict / set type in your language does not maintain order, you may need to keep a separate ordered array to complement your solution to prevent printing them in the wrong order and being considered a wrong solution. If you already have that covered, as the test case is long, you may need to use a lookup table for efficiency if your current implementation uses multiple nested loops to prevent timeouts.

1 Like

i don’t understand the case who return CAN’T
how can we obtain the state “CAN’T”???

I’m not really sure about what you’re asking… Do you have a problem in understanding the puzzle statement, or do you have a problem with a particular test case? Please provide more details.

for the output we have this : " If not possible: One line: CAN’T" but i don’t know how get this state exemple for test 3 why the ouput is can’t ?? i don’t understand the requirement to get " CAN’T"

The mapping must be consistent, so with the following input:

AA
BC

The output should be CAN’T, because the letter ‘A’ can’t be mapped to both ‘B’ and ‘C’.

ok thanks you it’s good now