[Community Puzzle] Prefix code

https://www.codingame.com/training/easy/prefix-code

Send your feedback or ask for help here!

Created by @chouch,validated by @amkad,@DomiKo and @Stilgart.
If you have any issues, feel free to ping them.

Hi, I am doing this problem in bash. I find problems by the test Inception, I am having problems by printing out things with break lines. Any suggestion?

I solved that problem. If you want to reproduce it the problem is the following: If you store a string with a break line in a variable and you try to echo, you will not display it correctly.
e.g:
export test=“asd\nXXXXXasd”
echo $test
Output:
asd\nXXXXXasd

Solution:
export test=$‘asd\nXXXXXasd’
echo “$test”
Output:
asd
XXXXXasd

Note here that distinction between single and double quotes is important.

I finally made it in bash. For those of you who are doing it in bash and are struggling with timeouts like me try to use less sub processes.

Hi, I work on this problem in C++. My program works for all examples, excepted with the 3rd example. In fact, the output expected is “DECODE FAIL AT INDEX 186” and I have also this, but before it I have this sentence “Invalid : extra bit at the end of the encoded text”. I can’t find from where comes this problem, if someone can help me to understand this ?

You’re supposed to exit if it fails.
In C++ you can put the fail message in a return statement so that it stops the main function.

Something like this:
return printf(“DECODE FAIL AT INDEX %ld”, index);