# The "Jumbled" Cipher

The elusive "Jumbled" cipher has stumped scientists and cryptographers alike...

Not really, but it will stump you soon...

The Jumbled Cipher is a mysterious text cipher that puts text into an unreadable state, making it appear jumbled. Nobody to this point has been able to decode the messy ASCII cipher into its original format.

Here are some examples, showing an example of the algorithm at work:

hello world                 =>      ĄûĎĎđPĥđĚĎú
Puzzling Stack Exchange     =>      ÈģĮĮĎąĐýPËĢñóćP«ĬóĄñĐýû
sp00ky scary                =>      ěĘxxćĭPěóñĚĭ


Your job is to crack the code. You need to figure out what the algorithm is that is being used to encode the string. Your hints follow (more will be added every day the question is not solved).

Hint 1

Take what you will from this riddle: Rumors of an all-smart man were passed around, however, I knew this man, and he was only a bit wise - the rumors were just not true.

As an extra challenge (optional), you can create an encoder and decoder in the programming language of your choice. It may be featured in this post. Good luck cracking the code!

• This looks like a decent puzzle from what I can tell, but are the diacritics really necessary? As it stands, it appears that a good portion of the puzzle is figuring out the ASCII codes for all the special characters (since the sample text does not use every letter of the alphabet nor every digit). Not very ...ah... puzzl-ey May 4 '19 at 16:02
• Given that this is a [computer-puzzle], figuring out the (not ASCII but Unicode) codes shouldn't be too much work. May 4 '19 at 16:07
• @GarethMcCaughan that's true - I was expecting to find a pattern along the lines of "A" is "0", "B" is "1", "C" is "2", so D must be 3, but now I have to find that precise character (taking each number to be some sort of pattern in the diacritics). May 4 '19 at 16:12
• Best just to think of the ciphertext as characters rather than as letters plus diacritics, I think. May 4 '19 at 16:16

In each string,

a character with ASCII code c is replaced by one with Unicode code point computed as follows: add together c and floor(c/2), and then subtract 1 if c is odd and another 3 if c has bit 1 set. (That is: write c in binary: if it ends 00, 01, 10, 11 then subtract 0, 1, 3, 4 respectively.)

It feels as if there should be a more elegant way to describe this. Ah, here's one:

compute 2.5*c and then subtract 1.5*(c&3) where the & is bitwise.

Here's another equivalent description:

character c is replaced with c + 1.5*c' where c' = c-(c&3) -- i.e., c' is c with its two low bits cleared. (Which can therefore be multiplied by 1.5 safe in the knowledge that the result is an integer.)

Presumably

the input doesn't have to be within the ASCII range, but of course for some inputs there might not be a Unicode character with the prescribed number...

Solving process:

I looked at the plaintext/ciphertext pairs given and noticed that it seems to be a simple substitution cipher. The first thing that jumped out at me was the 0->x pair, not least because I think it's the only one where the ciphertext is within the ASCII range. 0 is 48 and x is 120, which is ... suggestive. So then I tried mapping c to 2.5*c, rounded one way or another, and noticed that the results were close but wrong. Next thing was to look at the differences. Hmm, they're all (1) small and (2) negative. So which numbers yield which differences? Ah, looks like it only depends on c mod 4. From there it's just a matter of looking for not-too-horrible equivalen ways to describe the calculation.

• Huh, you took a completely different path than I expected. Not quite the solution, though. May 4 '19 at 16:08
• Do you mean that my algorithm doesn't give the same output as yours? May 4 '19 at 16:08
• No, I mean you took a different approach than me. Did you test it with some of the example strings I have in the post? May 4 '19 at 16:17
• Of course -- what else could I have done? :-) I'll add a few words about my solving process to the answer. May 4 '19 at 16:18
• Sounds good! It would be cool if your algorithm results matched mine. May 4 '19 at 16:19