## The chained letters puzzle

I just invented a type of puzzle that I call “chained letters”.

The purpose of the puzzle is to decode a number sequence in order to find the underlying word.

Let me explain.

First of all, this puzzle is meant to be case insensitive.

We begin with the most obvious correspondence: the 26 letters of the alphabet and the numbers from 01 to 26. So, the letter A corresponds to the number 01, the letter B corresponds to the number 02, and so on up until the letter Z which corresponds to the number 26.

Now we choose a word, whatever word we want. It would be best if it is a word with many letters. Why this is so, will become apparent later.

Then we substitute each letter of the original word with its corresponding number.

If we stop here, then it would be the easiest task in the world to decode the word from the number sequence.

But we do not.

What we do next is to change each number, advancing its value in a cyclical way. The change is as much as the value of the previous number in the sequence. And the first letter of the word, well, we change that according to the value of the last number.  This is depicted in the following image. What does advancing in a cyclical way means? It means that if we have the number 24, then advancing it by 01 will give us the number 25. Advancing it by 02 will give us the number 26. Advancing it by 03 will give us the number 01. Advancing it by 4 will give us the number 02. And so on. We go from 01 up to 26 and then we wrap back and continue from 01 onwards again.

Let me give you an example.

First of all, it will help if I write down the correspondence between letters and numbers.

01 A
02 B
03 C
04 D
05 E
06 F
07 G
08 H
09 I
10 J
11 K
12 L
13 M
14 N
15 O
16 P
17 Q
18 R
19 S
20 T
21 U
22 V
23 W
24 X
25 Y
26 Z

Suppose we want to code the word “JUSTICE”.

We begin with the letter sequence:

J U S T I C E

Then we create the initial number sequence:

10 21 19 20 09 03 05

This is easy to do.  The letter J corresponds to 10, the letter U corresponds to 21, and so on.

Now we begin the difficult part. We will change the value of each number according to the number that precedes it. And for the first number, we will change its value according to the last number.

Let’s begin.

It is important to keep the initial number sequence intact and create a new one to be the result of our operations.

So let us begin by changing the second number.

The second number is 21. The number that precedes it is 10. So we will advance 21 by 10. Normally, this would give us 31. But we will not perform a regular addition. We will perform a circular addition where we wrap at 26. Thus 21 will become 05. So we will substitute 21 with 05.

The third number is 19. The number that precedes it is 21. So we will advance 19 by 21. Normally, this would give us 40. But since we are doing a circular advancement, 19 will become 14. So we will substitute 19 with 14.

The fourth number is 20. The number that precedes it is 19. So we will advance 20 by 19. Normally, this would give us 39. But since we are doing a circular advancement, 20 will become 13. So we will substitute 20 with 13.

The fifth number is 09. The number that precedes it is 20. So we will advance 09 by 20. Normally, this would give us 29. But since we are doing a circular advancement, 09 will become 03. So we will substitute 09 with 03.

The sixth number is 03. The number that precedes it is 09. So we will advance 03 by 09. Normally, this would give us 12. And since 12 is less than or equal to 26, we will accept this result as is. So we will substitute 03 with 12.

The seventh and final number is 05. The number that precedes it is 03. So we will advance 05 by 03. Normally, this would give us 08. And since 08 is less than or equal to 26, we will accept this result as is. So we will substitute 05 with 08.

Now let us change the first number. There is no number that precedes it, but we do everything circularly here, so we might as well continue in this path. We will use the value of the last number to advance the first number. So the first number is 10. And the last number is 05. So we will advance 10 by 05. Normally, this would give us 15. And since 15 is less than or equal to 26, we will accept this result as is. So we will substitute 10 with 15.

Please note that we could have done any of these operations in any order. We need to keep the initial number sequence intact. Then we can substitute each number with its advancement in any order. In the example above, I calculated the substitution of the first letter as the final operation, but I could have done it in the beginning or at any other time.

So let us see the final number sequence that we created:

15 05 14 13 03 12 08

Let us see the corresponding word:

O E N M C L H

So, if we give this word (that we calculated as our result) to someone, could they decode it? Could they derive the original word it came from, if the algorithm that we used is known to them?

It is important to keep the algorithm public and everyone should know the algorithm, meaning the procedure we used to derive the result word.

So, can someone derive the original word from the coded word? If someone knows our algorithm, and we give them the word OENMCLH, can they find out that the word it came from is JUSTICE?

Well, the result word does not resemble the original one, except for the fact that in this puzzle the initial word and the final word will always have the same number of letters. But even if the result word looks completely scrambled, we can reconstruct the original word it came from as follows:

We take the result word and we substitute the corresponding numbers.

So from

O E N M C L H

we come to

15 05 14 13 03 12 08

This is straightforward.

Next we can begin with any number and move in a cycle. So we might as well begin the first number.

The first number is 15. We know that we arrived at this number by augmenting the number that was there initially, using the last number in the sequence which is now 08. Yes, the last number is now 08, but we do not know what it was when we used it to augment the first number.

No number in this sequence is the original number that existed in the initial sequence. All numbers have been changed.

So what are we to do?

What we can do is suppose that the first number was originally 01. And see where this takes us.

Next we will suppose that the first number was originally 02. And see where this takes us.

And so on, until we check for all 26 possibilities for the first number.

Each time we suppose that the first number was something (from 01 to 26), we will come up with a number sequence. Then we will gather the 26 resulting number sequences and see which one corresponds to a valid word. The 25 other number sequences will be discarded. But it gets easier. Most, if not all, of the 25 number sequences, will not even be completed, since there will be an inconsistency when we wrap around the final to the first letter. So, most if not all of the 25 number sequences will be completely invalid. This is not because they will result in a meaningless bunch of letters, but because they will not result in a valid sequence that wraps validly around itself. This is because by supposing that the first letter was something, we will finally end up calculating the last letter, but when we derive this last letter, it should produce the assumption we made for the first letter. Usually, the only case that this will happen is when our original assumption for the first letter was correct.

Anyway, what we should do is assume each of the 26 possible numbers for the first number and calculate the original sequence that corresponds to this assumption. If we are able to finish the calculation and get a valid result, this is a strong hint that this result may correspond to the word we are looking for.

In the end, we will collect all the valid resulting sequences (theoretically their number will be from 1 to 16, but usually there will only be 1) and see to what words they correspond. The word we are looking for should be straightforward to find.

OK, let us see how we will proceed to find the original number sequence from the final number sequence

15 05 14 13 03 12 08

We will have to make 26 assumptions and then the calculations that correspond to each one of these assumptions.

So we will first assume that the original first number was 01.

So the corresponding calculated assumed original initial sequence is

01 …

If the original first number was 01 and now it is 15, this means that it was shifted by 14. So this means that the last letter was originally 14. We will keep that in mind. When we arrive at the end of our resulting original sequence and the last number is 14, this sequence will be a strong candidate for our final check. If not, this means that this sequence is definitely invalid, the assumption that the original first number was 01 is definitely invalid and we can safely discard this assumption and this resulting initial sequence.

By assuming that the first number was originally 01, we can deduce that the second letter was originally 04. This is because it is now 05 and its preceding letter was 01, so from 04 it was shifted to 05.

So the corresponding calculated assumed original initial sequence is

01 04 …

Now that we found the second number, we can find the third number. The third number is now 14, but since its preceding number was 04, then it means that it was originally 10 and it was shifted by 04 to become 14.

So the corresponding calculated assumed original initial sequence is

01 04 10 …

Now that we found the third number, we can find the fourth number. The fourth number is now 13, but since its preceding number was 10, then it means that it was originally 03 and it was shifted by 10 to become 13.

So the corresponding calculated assumed original initial sequence is

01 04 10 03 …

Now that we found the fourth number, we can find the fifth number. The fifth number is now 03, but since its preceding number was 03, then it means that it was originally 03 and it was shifted by 26 to become 03. In this circular addition, there is no zero as a number. We do not have any zeros.  But if we add 26 to a number, we get the original number.

So the corresponding calculated assumed original initial sequence is

01 04 10 03 26 …

Now that we found the fifth number, we can find the sixth number. The sixth number is now 12, but since its preceding number was 26, then it means that it was originally 12 and it was shifted by 26 to become 12. I repeat from the previous paragraph: In this circular addition, there is no zero as a number. We do not have any zeros.  But if we add 26 to a number, we get the original number.

So the corresponding calculated assumed original initial sequence is

01 04 10 03 26 12 …

Now that we found the sixth number, we can find the seventh number. The seventh number is now 08, but since its preceding number was 12, then it means that it was originally 22 and it was shifted by 12 to become 08. I repeat from the previous paragraph: In this circular addition, there is no zero as a number. We do not have any zeros.  But if we add 26 to a number, we get the original number.

So the corresponding calculated assumed original initial sequence is

01 04 10 03 26 12 22

We finished, but… we found that the last number of the original sequence is 22. And we assumed that the first number was 01. Thus, in the final sequence it would have been shifted by 22 to become 23. But in the final sequence we have at hand, the first number is 15. Thus we arrived at an invalid resulting initial sequence. Thus, we can safely assume that 01 was not the first letter of the original initial sequence.

We can then assume that the first number of the original initial sequence was 02 and do all the calculations. And so on. Each time, we will keep the resulting initial sequence if it is valid, I,e, if the last number calculated validates the assumption of the first letter. And we will see which of the valid resulting initial sequences correspond to a legitimate word. But, usually, there will only be one valid resulting initial sequence.

So let us do the calculations for the correct assumption, to see how this goes.

The initial word was

J U S T I C E

and  the initial number sequence was

10 21 19 20 09 03 05

But the solver does know that. All the solver knows is the final number sequence

15 05 14 13 03 12 08

Now let us suppose that the solver has tried all possible cases up from 01 up to 09 for the first number of the original sequence and now the solver is about to try the case for the first number of the original sequence being 10. We know that this is the correct assumption, but the solver does not. Let us see how this goes for the solver.

So the solver assumes that the original first number was 10.

So the corresponding calculated assumed original initial sequence is

10 …

The second number in the final sequence is 05. This means that the second number of the initial sequence was 21. This is because 10+21=05 in our circular addition.

So the corresponding calculated assumed original initial sequence is

10 21 …

The third number in the final sequence is 14. This means that the third number of the initial sequence was 19. This is because 21+19=14 in our circular addition.

So the corresponding calculated assumed original initial sequence is

10 21 19 …

The fourth number in the final sequence is 13. This means that the fourth number of the initial sequence was 20. This is because 19+20=13 in our circular addition.

So the corresponding calculated assumed original initial sequence is

10 21 19 20 …

The fifth number in the final sequence is 03. This means that the fifth number of the initial sequence was 09. This is because 20+09=03 in our circular addition.

So the corresponding calculated assumed original initial sequence is

10 21 19 20 09 …

The sixth number in the final sequence is 12. This means that the fifth number of the initial sequence was 03. This is because 09+03=12 in our circular addition.

So the corresponding calculated assumed original initial sequence is

10 21 19 20 09 03 …

The seventh number in the final sequence is 08. This means that the fifth number of the initial sequence was 05. This is because 03+05=08 in our circular addition.

So the corresponding calculated assumed original initial sequence is

10 21 19 20 09 03 05

And we finished. Now we must check the validity of the sequence. The last number produced is 05 and the first number is 10. Does 10+05 produce the first number of the final sequence? Yes, it does. 10+05=15, which is the first number of the final sequence.

Thus, the sequence we produced with the assumption that the first number is 10 is a strong valid candidate. And chances are slim to none that another valid sequence will emerge. But I suggest that the solver tries all 26 assumptions for the first letter of the initial sequence just in case.

So the corresponding calculated assumed original initial sequence is

10 21 19 20 09 03 05

And if we substitute the letters, we get the original initial word

J U S T I C E

Now this game can be played by choosing a word, encoding it using the circular algorithm I described and letting the solver deduce the way to decode the word. The solver should be able to deduce that she needs to try 26 possible assumptions for any letter position she chooses and move circularly calculating the resulting sequences. Of course, the solver can make the initial assumptions not for the first number but for any number in the sequence that she chooses. But there is no benefit or loss in what position she chooses to make the initial assumptions. But the solver has to deduce that she will have to make 26 assumptions and then perform the corresponding calculations for each assumption.

The word to be decoded should be long, in order to avoid letting the solver do the calculations by hand. This puzzle is meant to train aspiring cryptographers, so it would be best if it is designed such that it would persuade them to use a computer and create a program to do the calculations.

A student may create a program that decodes such a puzzle word and also a program that encodes (creates) such a puzzle word. And students can play against each other. One student can encode a word and the others could try and decode it.

Also, this puzzle can be made more difficult. For example, the symbols may be increased. As is, this puzzle deals with 26 symbols, the uppercase letters of the alphabet. Of course, a space, other symbols, the lowercase letters, numbers, etc. may be added. If we add, say, only a space, so the students can create an elementary sentence (just a space, no point, comma, etc) then the number symbols will be 27 and the addition will need to wrap at 27.

The difficulty of the puzzle can also be increased by circularly adding the previous, say, two letters to the current letter. And, in such a case, for the first letter, we would add the last and second before last letters. (Remember, we do things circularly here; not only the addition is circular, but also the way each letter is produced from the previous one – or more). So, if we choose to add the previous two letters to the current letter in order to shift it, we would have to make 26 *26 = 676 assumptions. So, to solve the puzzle we would need to calculate each assumption: each permutation of the first two letters, assuming we choose to work from the beginning of the number sequence. (Because, again, I am stressing that we can choose to begin to work from any number position in the sequence. And we can choose to proceed from left to right or from right to left.) Anyway, in such a case, we would assume that the first and second numbers in the initial sequence were 01 and 01. And we would find the third number, based on the third number of the final number sequence. And based on that, we would find the fourth number and so on until we calculated the whole sequence. And then we will try the assumption of the first number being 01 and the second number being 02. And so on, until we try all 676 assumptions.

So how may this puzzle appear? How can we pose the question to solve the puzzle? Here is an example:

A word is encoded using the following algorithm. Each letter corresponds to a 2-digit number. The letter A corresponds to 01, the letter B to 02, all the way to the letter Z which corresponds to 26. By substituting each letter with its corresponding 2-digit number, an initial number sequence is produced.

Then, this initial number sequence is transformed as follows to produce a final number sequence. We take each 2-digit number and we add the previous (position-wise) 2-digit number. The resulting 2-digit number will be used in its place in the resulting number sequence. As far as the first 2-digit number is concerned, we will add the last 2-digit number to it to produce the first 2-digit number of the resulting number sequence.  This concept is depicted in the accompanying image, where a six letter word is encoded. In order for the resulting 2-digit number to always be from 01 to 26, we always perform a circular addition (instead of a normal one), where we wrap our results at 26. Thus, a few examples of this circular addition are 01+01=02, 01+25=26, 01+26=01, 10+22=06, 26+26=26, etc. So, 00 does not exist and adding with 26 equals the number that is added to 26.

Finally, in the resulting number sequence each 2-digit number is substituted with its corresponding letter. Given this resulting word, your task is to decode it, thus finding the original word.

So, given the following word, what was the original word that was used to produce it?

R  X  W  W  S  R  M  Y  Y  C  S 