# [Community Puzzle] Decode the message

I have the same problem.
All my tests in the IDE pass but not the sixth test in the validators.

I think a test should be added in the IDE to be able to find the problem.

Iāve sent the validator to both of you, can you tell me what was the problem ? Seems like itās common to fail on it.

With Kotlin the test 6 and 7 failed for me as well. I identified a possible problem with both tests: The input P is to big for an (32 bit) integer and therefore it throws an exception on parsing it into an integer.

Iāll might change my implementation today to use the Java BigInteger class or Long to store the input. But it makes the code more complex and it isnāt that āeasyā (in terms of the difficulty shown) anymore.

By the way: I liked the puzzle. Gave me something to think and was very interesting

It was asked to creator to fix the stub from int to long many times ā¦
Looks like it is too complicated for him (or he doesnāt care) so i did it myself

Now itās fine I finished the puzzle.

To explain you the problem I had I am gonna give you a simple example.
encoded = 974
alphabet = āH_eo: Wrld!ā

The length of the alphabet is 11. So what I do is:
974 / 11 * 11 = 968
6/ 11 = 0 (so index -1 and therefore an error)
6 / 1 = 6 (so index because itās last element)

While the encoded message was built this way:
121 * 7 = 847
11 * (10 + 1) = 121
1 * 7 = 7 (6 because itās the last element)

So when there is a string with a latest letter in the alphabet it was producing an error in some cases.

1 Like

Thanks for the feeback, that offset by 1 was intended actually.
Iāll swap the test and validator 6 so people have a chance to understand whatās going on.

All test are OK except Validator 4.

Validator 4:
Input:

``````117
1234567890
``````

Output:

`811`

Good luck!

After analysis, I think the problem encountered in test 6 is indeed a bug.
p = 34170657950616
c = āH_eo: Wrld!ā
result = 'Hello! World ā
In the system described, the last letter of the alphabet cannot be used by indicating the offset of the last character, otherwise the latter interferes with the following character (construction from right to left). We can correct this problem by using offset 0 for the last character, this does not stop the problem in the rest of the logic, we just have to deal with the case of offset 0 in the code (it must return the last character ). In this case the code must be 34170638463445 (which uses 0 for the ā!ā) And not 34170657950616 (which uses 11)

I donāt think is related to Cryptographyā¦

Same here.
Thereās a bug in test case 6, with
p=34170657950616 , c=āH_eo: Wrld!ā
iām getting āHello !WWorldā.
And with p=34170638463445, as you mentioned, and with the same c iām getting
āHello ! Worldā

No problem with the other test cases and validators.

Thereās indeed a bugā¦ but in your code.
The test canāt be ābuggedā since it consist as nothing more than the given input/output values. And more than 500 users (including me) have a fully working code, simply following whatās said in the statement.
So you better read the statement again, and check back your codeā¦

Hello,

The encoding scheme instructions are a bit unclear to me. I canāt tell if I am supposed to go through all combinations until Iāve computed the guess at index p (test 1 seems to indicate this), or if it is some other encoding scheme that Iāve gotten completely wrong (like dividing the number by alphabet size, and somehow ending up at the correct encoding)?

The instructions mention āhelloā being encoded as 7073801. So I suspect it is because āhelloā is the 7073801āth combination with that alphabet?

Iāve just begun here, but this is the first puzzle that has had me this stumped

Your interpretation of the āhelloā example is correct. And while you can go through the combinations one by one to reach the answer, there are more efficient ways to calculate it.

Also, donāt assume there must be a single correct approach to a problem. There are often multiple ways

1 Like