[Community Puzzle] Character replacement problem

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @renzyGo,validated by @Ayza,@NinjaFoxYT and @FredericLocquet.
If you have any issues, feel free to ping them.

Hey there, I don’t quite understand why testcase 7 and 8 are not passing
for testcase 7 I got

ty rt er we

and string

wwwwweeeeerrrrrtttttyyyyy

which would yield the following conversions

wwwwweeeeerrrrryyyyyyyyyy

wwwwweeeeetttttyyyyyyyyyy

wwwwwrrrrrtttttyyyyyyyyyy

eeeeerrrrrtttttyyyyyyyyyy

e.g.

eeeee
rrrrr
ttttt
yyyyy
yyyyy

but the test case expects this result →

Failure

Found:

eeeee

Expected:

yyyyy

any reason why that is?

1 Like

Hi,

It’s because conversions are chained, you keep converting as long as some rules apply to characters in the string.
So it would be:

wwwwweeeeerrrrrtttttyyyyy
eeeeerrrrrtttttyyyyyyyyyy
rrrrrtttttyyyyyyyyyyyyyyy
tttttyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyyy
2 Likes

A graph tag is missing, here.

1 Like

A proper cycle detection is not needed here, you can just run it and check if it still evolves at the (n+1)-th step (where n is the number of replacements given).

1 Like

the 15 < s.length() < 30 constraint is incorrect…

2 Likes

How is validator 4 different from the tests?
@renzyGo

1 Like

Send me your code in private, I’ll send back what’s wrong.
There is nothing that different from the test.

1 Like

Thank you nicola, but I want to fix it myself.
There is a difference but it might be my code of course.
You can send me the validator instead?

1 Like

Hi,

The difference between Test 4 & Validator 4 is the number of rules it takes to reach a loop.

You could try with something like that as custom case (this is not the validator)

ab dc ba
4
aaaa
bbbb
cccc
dddd
1 Like

My Python script does not check if there is a loop.

Same conditions but not same text.

1 Like

Try this custom test (similar to validator 4) :

Input :

ak kp pp pk
4
aaaa
ckkc
pqpq
qpqp

Expected output
ERROR

This case (or a variant) should be added as a test in the contribution.

2 Likes

Hi,
How is validator 8 different from the tests ? My program is ok for all tests but not for validator 8.
Thx

1 Like

Different letters and different order of the instructions. Output is similar to test 8, i.e. all letters are converted to the same letter in the end.

1 Like

Ok, I don’t see my mistake.

1 Like

Thank you @nicola @cedricdd @b0n5a1 :slight_smile:

Validator 4 is different in where the chain of instructions short circuits I think.
Like b0n5a1 wrote.

Test 4 instructions : “zz zi ia az”. zz is ignored.
From z to i. From i to a. From a to z.
This chain starts at the first instruction zi and there is also where it starts over again in the endless loop.

Validator 4 looks something like “ak kp pp pk”. pp is ignored.
From a to k. From k to p. From p to k.
The chain starts at the first instruction ak but the endless loop starts over at the second instruction kp.

In my code I looked for a chain and compared the instructions in the chain to the first instruction in the chain to see if it started over again. An endless loop.
I didn’t think of that it doesn’t have to be the first instruction in the chain that is the “starting over point”.

Validator 4 is bad.
Compared to test 4, validator 4 should look something like this:
Test 4 -------------- “zz zi ia az”
Good validator – “aa ab bc ca”
Bad validator ---- “aa ab bc cb”

@renzyGo @Ayza @NinjaFoxYT @FredericLocquet
Please fix validator 4.

1 Like

Your interpretation of “test and validator should be similar” is a bit too strict in my opinion. Test 4 and Validator 4 are similar enough. And what’s more, it’s embarrassing that particular validator is actually shown as one of the examples in Goal section, and hence that should be fixed instead…

1 Like

It should be very strict. The validator is only to prevent hard coding. Not to test any functionality of the code.
And since the feedback is 0 from a validator fail, it’s very important they are very close to the tests.

2 Likes

I guess many validators in many puzzles will not satisfy your interpretation…

2 Likes

Thank you.
I fixed the Tag, Constraints, Goal Section, and the Validator case.
I had’nt noticed those mistakes. So thanks for let me know them.
Thanks.

1 Like