https://www.codingame.com/training/medium/byte-pair-encoding
Send your feedback or ask for help here!
Created by @fpringle,validated by @murrayr,@xspeedasx and @Radu_Sav.
If you have any issues, feel free to ping them.
https://www.codingame.com/training/medium/byte-pair-encoding
Send your feedback or ask for help here!
Created by @fpringle,validated by @murrayr,@xspeedasx and @Radu_Sav.
If you have any issues, feel free to ping them.
Continuing the discussion from [Community Puzzle] Byte pair encoding:
What about “aabdaabcab” case?
Can you expane what answer should be for this input?
aabdaabcab:
YdYcZ
Z = ab
Y = aZ
input -----------------------
aabdaabcab
process 1 -----------------------
process 2 -----------------------
return -----------------------
YdYcZ
Z = ab
Y = aZ
Not passing last test case any hint
I don’t think there is anything special about the last test case…
I would suggest looking at the expected output to see where the encoding rules differ from your answer
(you can use the “Show testcases” button to see the full expected output for each test).
thanks! never knew we can see test case expected like that(Im new to the platform).
And Finally solved!!
Continuing the discussion from [Community Puzzle] Byte pair encoding:
Hi,
Could you help me ? I don’t get the third test:
word = aaaaaaaaaaaaaaabbbbbbbbbbbbbbbcccccccccc
First try:
pair identified : “aa”
==> word = ZZZZZZZabbbbbbbbbbbbbbbcccccccccc
Second try :
pair identified : “ZZ”
==> word = YYYZabbbbbbbbbbbbbbbcccccccccc
I don’t get why the word should be “ZZZZZZZaYYYYYYYbcccccccccc” as the first pair is “ZZ”
I may have missed a rule…
Your “second try” is incorrect. “ZZ” is not the most common pair.
value: aaaaaaaaaaaaaaabbbbbbbbbbbbbbbcccccccccc
most common pair: aa, replacement Z
value: ZZZZZZZabbbbbbbbbbbbbbbccccccccccmost common pair: bb, replacement Y
value: ZZZZZZZaYYYYYYYbccccccccccmost common pair: cc, replacement X
value: ZZZZZZZaYYYYYYYbXXXXXmost common pair: ZZ, replacement W
value: WWWZaYYYYYYYbXXXXXmost common pair: YY, replacement V
value: WWWZaVVVYbXXXXXmost common pair: XX, replacement U
value: WWWZaVVVYbUUX
Recursion is not needed to solve this problem. A single while loop that just checks if there is more to be done is sufficient.