[Community Puzzle] Decode the message

https://www.codingame.com/training/easy/decode-the-message

Send your feedback or ask for help here!

Created by @BiMathAx,validated by @anon91538998,@Nazdhun and @NitMpez.
If you have any issues, feel free to ping them.

My two cents: That’s a pretty big leap between Tests 4 and 5 with not a lot of description to help the solver.

I’m stuck too at the test 5 and 6 but I pass test 7… Any idea why?

I found the problem in my 2-loop, I must work just on words of the last length i.e the set of 1char or 2 chars or 3 chars, etc…

A fun little puzzle.

I found the English instructions a bit difficult to understand; particularly the description of the encoding scheme. Maybe the French ones are clearer?

I would have enjoyed some longer messages in the test cases.

While the types of the problem inputs are present in the auto-generated code, it would be nice to have them explicitly stated in the instructions as well.

Do ā€˜hello’ and Ā«bonjourĀ» really encode exactly to the same value ā€˜7073801’ with the 26-letter alphabet, just as the bilingual statement suggests? Seems an unlikely coincidence to me, especially as encoding is supposed to be unique…

2 Likes

No it doesn’t :wink: I’ve modified the value in the description.
I’ve also modified all the tests for consistency, all characters are now unique in their alphabets, and the last ones are less forgiving.

@MACKEYTH I agree it could be clearer, but figuring out how the value is computed is also part of the puzzle. If you have a better description in mind feel free sharing it.

1 Like

FYI the English instructions appear to be a Google Translate of the French:

You are an FBI agent and you intercepted a message from terrorists.
This message must be decrypted, and for this you have access to 2 pieces of information: P and C.

ā€œCā€ is the alphabet used to write the message and contains all the letters / characters needed to decode it.

P corresponds to the coded value of the message.
Fortunately, you know how this value is calculated, and now you need to reverse the following process:

  • Assuming that the alphabet is ā€˜abcd’, each letter is associated with its index: a = 0, b = 1, c = 2, d = 3.
  • Then a new letter is added for the following values: aa = 4, ba = 5, ca = 6, da = 7, ab = 8, bb = 9, cb = 10, etc.
  • The whole message thus obtains a unique value. For example, with a full alphabet (26 letters), ā€œhelloā€ would be 7073801.

Make it agent!

Actually it’s the opposite, the french text was made from the english one.
But I’m wondering if the french part should not be removed. It’s not my puzzle so I’d feel bad reworking everything :grimacing:

Unless I’m wrong, the general idea is everything in English, thus it should have been removed before approval (doubly so if one is just a straight translation of the other). That’s my vote.

How about something like:
[spoil]ā€œP is a summation of n terms (with n being the length of the message and the alphabet index starting at 0) as follows:
(alphabet index of letter 1) + ( ( (letter 2 index) + 1 ) * alphabet size^1 + … + ( ( (letter n index) + 1 ) * alphabet size^(n - 1) )ā€[/spoil]

Heh, that may be a bit TOO descriptive. :smile:

The description should not give a general formula, otherwise there’s no puzzle left :slight_smile:
I’ve updated the description, can you tell me if it’s clearer now ?

It’s nearly the same puzzle:

2 Likes

Is the only difference that the String would be in reverse order?

Then the argument is (and I know I’ve beat this horse dead), why is one of these hard and the other easy?

Because it’s an old puzzle from 4 years ago, difficulty was kind of a mess back then. And it cannot be edited anymore (unless you ask a CG member I guess).

Was it really a mess back then? Or is it more so now? I know this is slightly off topic here and I bring this up a lot but what is an ā€œeasyā€ puzzle? What is a ā€œhardā€ one? If there are no rules codifying how that is decided, then we keep ending up back here to the same spot.

2 Likes

Typically many hard/very hard puzzles from back then would be downgraded in difficulty now, sometimes by a lot like in this case. Since the difficulty ranking has never been formalized it’s still a bit messy, but imo it’s in a better place currently.

1 Like

All test cases are passing my JS code, however validator 6 isn’t.
Can we get a bit more description about validator 6?
I can’t get my head around it.
Thanks

1 Like

For anyone trying to do this problem, I suggest first write an encode function to encode a string into a number. Then you write your decode function to reverse the number back into the string.

Doing this way is like having a unit test that you can try plenty of self-made test cases, encode and then decode and then match the result with your own original string. Very soon you will discover where the bug is.

3 Likes