Cryptic Crossword

Amateur Crypto and Reverse Engineering


Introduction

Reverse engineering is a special subgenre of computer programming. It's about the closest that I as a programmer get to being a scientist. Gather data, formulate a hypothesis, test, refine, repeat: reverse engineering is basically applying the scientific method to a very, very small knowledge domain. If you've never tried to reverse-engineer a program before, you may be wondering how one goes about such a task. The following essay retraces one of the more colorful reverse-engineering problems that I've pursued.

How all this started was that a friend of mine was contributing to an iOS application for crossword puzzles. This was in the early days of the first iPhone, and they wanted to get their app into the store quickly, before this tiny niche was saturated. The program was working, but it was missing one very small feature — namely that it couldn't unscramble scrambled crossword puzzles.

Let me back up a bit and explain. There is a widely used file format for crossword puzzles, called the .puz file format. (Or at least that's what I called it; I don't know if it has a better name.) The file format was created back in the 1990s by a software company called Literate Software, and they used it in their own application, "Across Lite". that allowed you to both create and solve crossword puzzles in their file format. Apparently they had the good fortune to become a de facto standard, so it's pretty much the main file format to use, if you're a crossword application. As far as I know they never published a spec for their format; however, other people had taken the time to reverse-engineer it and make the description publicly available. My understanding is that the company actually made its money not from the software, but by licensing the right to sell crossword files made with its software. So, even though they may not have officially approved of the reverse engineering, they probably didn't mind, since it would only help cement their file format as a standard. I'm fuzzy on the historical details here, but anyway the upshot is that the only available descriptions of this file format, which is pretty much the standard format for crossword puzzles, was written by people outside of the company.

Fortunately, the file format is pretty straightforward. As you might expect, it's a binary file format. The header includes things like the width and height of the grid, and the number of clues.

0000000: FC25 4143 524F 5353 2644 4F57 4E00 02EA .%ACROSS&DOWN... 0000010: 4BD0 B00C ABE5 B845 312E 3200 0000 0000 K......E1.2..... 0000020: 0000 0000 0000 0000 0000 0000 0F0F 4E00 ..............N. 0000030: 0100 0000 4641 5445 2E41 5741 5348 2E41 ....FATE.AWASH.A 0000040: 574F 4C4C 4945 532E 4355 5249 4F2E 5348 WOLLIES.CURIO.SH 0000050: 4F45 454C 4543 544F 5241 5445 2E53 495A OEELECTORATE.SIZ 0000060: 4541 5353 2E45 5253 542E 4449 4554 4544 EASS.ERST.DIETED 0000070: 2E2E 2E43 454E 542E 484F 5354 4553 5352 ...CENT.HOSTESSR

After the header, the file consists of all the strings, with the first one being the completed grid, which you can see the beginning of in the sample here. Black squares are indicated with ASCII periods. After the answer grid would come the player's working grid, then the list of clues, and then some miscellaneous string data such as the crossword's title and author.

Here's a breakdown of the file header.

Description Length Details
File checksum 2 short
Magic 12 The ASCII text: "ACROSS&DOWN\0"
Base checksum 2 short
Masked checksums 8 short[4]
File Version 4 The ASCII text: "1.N\0" (N varies)
Unused 2 set to uninitialized garbage values
Unknown 2 zero unless scrambled
Reserved 12 set to uninitialized garbage values
Width 1 char
Height 1 char
Number of clues 2 short
Bitmask 2 normally set to 0x0001
Bitmask 2 0x0004 = scrambled

I don't know why anybody thought the file needed six different checksums. (Even better, four of the six checksums are masked: their value is XORed with the ASCII characters "ICHEATED". I'm guessing this was meant to discourage people from manually modifying existing files to make their own crossword files without using the software.) Fortunately, someone besides me had already figured this stuff out. There was one aspect of the file format, however, that was missing from the available descriptions.

One feature of the Across Lite program is that once you had created a crossword, you could opt to have it "scrambled". Normally, the completed grid (i.e. the crossword with all of the answers filled in) was stored in the file in plaintext. But that meant that a motivated user could examine the binary file contents to look up the answers (as we just did). Scrambling gave the puzzle author a way to prevent that.

After scrambling a puzzle, the file contents might look like this:

0000000: EDFB 4143 524F 5353 2644 4F57 4E00 04EA ..ACROSS&DOWN... 0000010: 4DF5 B00C AB05 B845 312E 3200 0000 8B6B M......E1.2....k 0000020: 0000 0000 0000 0000 0000 0000 0F0F 4E00 ..............N. 0000030: 0100 0400 4846 4A49 2E46 4241 4746 2E50 ....HFJI.FBAGF.P 0000040: 5A44 4C49 4342 5A2E 534D 4549 492E 485A ZDLICBZ.SMEII.HZ 0000050: 4F45 514C 564E 4E50 4E4B 4D56 2E54 414D OEQLVNNPNKMV.TAM 0000060: 5258 5358 2E4F 5557 4F2E 5848 5951 4C56 RXSX.OUWO.XHYQLV 0000070: 2E2E 2E46 5144 4C2E 5952 4659 4F4D 4157 ...FQDL.YRFYOMAW

When you ask to have a puzzle scrambled, the application provides you with a key in the form of a four-digit number. (In this particular case, the key is 5274.) If someone later asks to unscramble the puzzle, the Across Lite application will prompt them for the key, and if they don't provide the correct key, they can't unscramble the solution.

The reverse-engineered description of the .puz file format had absolutely nothing to say about the nature of scrambled files. And this was my friend's problem. Without that information, their app wouldn't be able to unscramble a file, at all. The user could still work on the crossword, of course: the scrambling doesn't affect the grid's layout, or the clues. But users wouldn't be able to validate their answers.

FATEAWASHAWOL
LIESCURIOSHOE
ELECTORATESIZE
ASSERSTDIETED
CENTHOSTESS
REFITSJEWISH
ARITHKERNSOAF
NILEANNESDUPE
DEIOVENSLOSER
BODILYRACERS
GLUTEALPEPS
RESISTSLUESKI
OTTOREPUBLICAN
OMESIRATERAMS
MEREXENONABET
HFJIFBAGFPZDL
ICBZSMEIIHZOE
QLVNNPNKMVTAMR
XSXOUWOXHYQLV
FQDLYRFYOMA
WMIVLGIEXAGC
YMUXJEXZQGHHZ
MHIADGFKVOJII
SCYRCSEAJXEWQ
XIAMKZXMUHYP
WGUCFALKQOI
XLRILVMUILOBU
FCAZBWFCJCSDHZ
VWWUDCAZRXGLT
TICTBZDNMBHMT

One of the few advantages that crossword apps have over paper crosswords is that at the end, you can check your answer, and the program can tell you whether or not it's correct. Or it can tell you how many letters are wrong, or it can highlight the squares that are wrong, or just one wrong square, etcetera etcetera. But their app couldn't do that with a scrambled file, even if the user had the four-digit key!

As it happened, the majority of crossword publishers didn't bother to scramble their files. So they were tempted to just release their app without proper support for that feature. Unfortunately, one of the few publishers that did use scrambled files was the New York Times. (They would publish the scrambled file, and then publish the four-digit key the next day, on the same schedule as the print version published the answer grids.) Having a feature that works on everyone's crosswords except the New York Times is kind of like a wedding band that can play everything except the Wedding March. For a lot of potential users, that would be a deal-breaker.

So, my friend contacted me and described the situation, and asked: Do you think you might be able to reverse-engineer this scrambling algorithm? My response was: maybe. Hard to say, but I'm willing to try. Privately, though, my reaction was THIS IS MY DREAM PROJECT AND THERE IS NO WAY I'M NOT SPENDING ALL AVAILABLE FREE TIME ON THIS.

Getting Started

The first step, as it turned out, was just getting the Across Lite program running for myself. To my surprise, they actually had a Linux binary available. Unfortunately, it had a library dependency on a remarkably ancient version of the C++ standard library that pre-dated ANSIfication. After an unsuccessful attempt to track down a copy of this library that would run on a modern kernel, I wound up just using the Windows version of the program, running it under Wine. It was a bit slow to start up, but otherwise ran fine.

So this is what it looks like when you bring up the Across Lite program with a .puz file. The main focus of this interface is for working on solving the crossword, but this program also provides the ability to scramble the crossword, as you can see from the opened menu.

When you use it, the program selects a four-digit unscrambling key, which it gives to you in a message box. You can then save the scrambled .puz file to disk. The key is not available after you close that message box, so it's up to you to make a note of it.

Once that was working, my next step was to write my own program to generate unscrambled .puz files as input. I could have used someone else's code, but since I was already studying the file format, it was easy enough for me to slap together a script that generated a .puz file from some basic input.

With that preparation out of the way, I was ready to actually start work. After brainstorming for a bit on where to begin, here are some of the things that I initially tried:

Something that my friend had noticed was that when we scrambled a puzzle twice in a row, the two keys would be different, but only in the first half. The third and fourth digits were the same. At first I thought that this might be due to scrambling the same grid, but further exploration suggested that it was entirely due to temporal proximity. So naturally, I tried running two instances of the Across Lite program at the same time, and hit Alt-S S on both of them as quickly as possible. In this way I obtained two grids scrambled with the same key.

With this technique, I had my first inroad, a way to start making some actual progress in the investigation. I could now create two crossword grids that differed in some specific way, scramble them both with the same key, and then compare the results, seeing directly how a change in input affected the scrambled output. (In fact, I found I could do up to four grids at once, and still have about a 50% chance of all four being assigned the same key.)

Initial Discoveries

One of the first things I tested was scrambling a grid of all As and an otherwise identical grid of all Bs.

AAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAA
SOWSSNOUVAN
NSOTWXSWWSX
XKPLQYSKORWS
SXKUQUXPTWX
UZVPMKPUQV
VUZVRVZVVMRQ
VVMNUZQ
NSRWXTRSSVMR
RNSRSRTVWM
YPUQXXNSSXT
TYPLPTPXLQPX
UQVNQUYPLQP
PUQASPQQQQQ
BBBBBBBBBBB
BBBBBBBBBBB
BBBBBBBBBBBB
BBBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBBBB
BBBBBBB
BBBBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBBB
BBBBBBBBBBBB
BBBBBBBBBBB
BBBBBBBBBBB
TPXTTOPVWBO
OTPUXYTXXTY
YLQMRZTLPSXT
TYLVRVYQUXY
VAWQNLQVRW
WVAWSWAWWNSR
WWNOVAR
OTSXYUSTTWNS
SOTSTSUWXN
ZQVRYYOTTYU
UZQMQUQYMRQY
VRWORVZQMRQ
QVRBTQRRRRR

The results were exactly what I had been hoping (though not really expecting): the scrambled all-B grid's contents were exactly one letter ahead of the contents of the scrambled all-A grid (with Z wrapping around to A). This shows that the grid's contents were not an input into the scrambling process, except at the very end. The scrambling therefore can only depend on the shape of the grid (i.e. its size and the placement of black squares), and of course on the four-digit key. While that's still a big space to explore, it's nowhere near as big as it would be if each letter in the grid could contribute to the scrambling of the other letters.

This meant that from now on, I could examine nothing but all-A grids, and not have to worry that I might be overlooking some important factor in the scrambling process. This was the first point that I was willing to say aloud that I thought that I would be able to solve it. I still couldn't say how long it would take, but I felt confident in predicting that it was ultimately doable.

The next thing to try, of course, was scrambling two grids of the same size but with different shapes.

AAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAA
SOWSSNOUVAN
NSOTWXSWWSX
XKPLQYSKORWS
SXKUQUXPTWX
UZVPMKPUQV
VUZVRVZVVMRQ
VVMNUZQ
NSRWXTRSSVMR
RNSRSRTVWM
YPUQXXNSSXT
TYPLPTPXLQPX
UQVNQUYPLQP
PUQASPQQQQQ
AAAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAAA
SPUQUWSQXWSX
NOWSMYNUPRWS
XSOTVQXWVTWX
SKPRSSOUQV
UXKLMUKMRQ
ZVPXVXPQVMR
VSTNZKS
VUZVQXRVTVW
NSRPXULSXM
RNSLQTSQPT
YPUWNUNZPLQX
TYPRAPPRQQQP
UQVQSOYSVANQ

The total number of white and black squares are the same in each grid — just their positions are different. As you can see, this time I was not so lucky: the two grids produced completely different encryptions, despite both of them containing all As. Or mostly different — as you might be able to tell, there seem to be a lot of similarities between the two scrambled grids, even though it's not clear that there's an actual pattern present.

To study this further, I created a series of very small grids (experimenting showed that the minimum grid size was twelve letters) with only minor variations in their layout. Once I had succeeded in scrambling all of them with the same key, I soon found the key to the how the scrambling algorithm was reading the layout. Can you spot the rule?

AAAA
AAAA
AAAA
ZSMO
UTPS
SYSP
AAAA
AAAA
AAAA
ZSYS
USMO
TPSP
AAAA
AAAA
AAAA
ZSTP
USYS
MOSP
AAAA
AAAA
AAAA
ZSTM
USYP
SOSP

It is simply that the letters are read from the grid vertically, not horizontally. Top to bottom, then left to right. The letters are assembled into a plain old one-dimensional string, scrambled, and then the result is then put back into the grid the same way — top to bottom, left to right. The actual positioning of the black squares is completely unimportant.

(This was further vindicated when I returned to considering the unidentified value in the header. The header contains a run of 8 values, each two bytes long, that are unused — and in fact many files contain random values here. Except, that is, for the second entry: This entry (labeled "Unknown" in the table up above) is always zero for normal .puz files, and non-zero for scrambled files. What its value meant, though, was an open question. I had guessed that it was a checksum representing the unscrambled grid, since Across Lite could tell if you tried to unscramble a grid with an incorrect key. But the number didn't actually match the checksum of the unscrambled grid, so I had set aside that hypothesis for the time being. Now, though, I tried taking the checksum of the unscrambled grid contents rearranged as a one-dimensional string, top-to-bottom left-to-right, and this matched the mysterious header value perfectly.)

So, I now knew that the main scrambling process was determined entirely by the number of letters in the grid and the four-digit key. No other aspect of the grid's contents or arrangement was an important factor. Again, this was a huge decrease in the potential solution space to explore.

The next test, though, was a point where things turned out to be less simple than I had expected. I scrambled a series of grids that differed in size by only one letter:

AAAAAAAAAAAAA
TQNNXWWUMVVPT
AAAAAAAAAAAAAA
NXWNQWOVMVSPPT
AAAAAAAAAAAAAAA
TQTQLCXXQUMPQXP

Although there are clear hints of shared patterns, the basic fact is that changing the grid size can affect every single letter in the scrambled grid. I had been hoping, now that I understood the ordering of the scrambled grids' contents, that I would find that even the size of the grid wasn't actually an important factor, and that the contents of smaller grids would just prove to be a subset of the larger ones. No such luck.

The next test also showed me that things were still more complicated than I had been expecting. Here are four crosswords, all scrambled with the same key, in which each grid differs from the previous one by only one letter. (Colors indicate the changed letter.)

AAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAA
SOWSSNOUVAN
NSOTWXSWWSX
XKPLQYSKORWS
SXKUQUXPTWX
UZVPMKPUQV
VUZVRVZVVMRQ
VVMNUZQ
NSRWXTRSSVMR
RNSRSRTVWM
YPUQXXNSSXT
TYPLPTPXLQPX
UQVNQUYPLQP
PUQASPQQQQQ
BAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAA
SOXSSNOUVAN
NSOTWXSWWSX
XKPLQYSKORWS
SXKUQUXPTWX
UZVPMKPUQV
VUZVRVZVVMRQ
VVMNUZQ
NSRWXTRSSVMR
RNSRSRTVWM
YPUQXXNSSXT
TYPLPTPXLQPX
UQVNQUYPLQP
PUQASPQQQQQ
BAAAAAAAAAA
BAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAA
SOXSSNOUVAN
NSOTWXSWWSX
XKPLQYSKORWS
SXKUQUXPTWX
UZVPMKPUQV
VUZWRVZVVMRQ
VVMNUZQ
NSRWXTRSSVMR
RNSRSRTVWM
YPUQXXNSSXT
TYPLPTPXLQPX
UQVNQUYPLQP
PUQASPQQQQQ
BAAAAAAAAAA
BAAAAAAAAAA
BAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAAA
AAAAAAA
AAAAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAA
SOXSSNOUVAN
NSOTWXSWWSX
XKPLQZSKORWS
SXKUQUXPTWX
UZVPMKPUQV
VUZWRVZVVMRQ
VVMNUZQ
NSRWXTRSSVMR
RNSRSRTVWM
YPUQXXNSSXT
TYPLPTPXLQPX
UQVNQUYPLQP
PUQASPQQQQQ

As you can see, in addition to being encrypted, the letters of the grid are also being reordered. So there was (at least) two steps to the scrambling process. My hunch was that the letters were encrypted first, and then scrambled. But that meant that I would need to be able to undo the scrambling step before I could even start to tackle the decryption. Of course it was entirely possible that I was wrong and the scrambling was done first, or that there were multiple interleaved steps of encryption and reordering. But as usual, we start by assuming that things are simple until they are proven to be otherwise.

Collecting Data: Script Everything

The other thing I found is that trying to obtain four separate files scrambled with the same key was annoying. I had to launch four separate windows, and then quickly select the scrambling menu option in each of them. Even if I didn't make any slips, I found that it would fail almost half the time, leaving some of the files with one key and the rest with a second key. By now I was doing lots of different comparisons, in search of more data, and so I realized that I needed a more reliable technique.

I found a handy command-line program called xdotool, which allows one to identify windows by their title text and inject mouse and keyboard events. A simple shell script then allowed me to reliably scramble two or more files in parallel.

for w in `xdotool search --title 'across lite'` ; do xdotool windowactivate $w sleep 0.1 xdotool key alt+s s 2> /dev/null sleep 0.2 done

This wasn't perfect — every once in a while I would still get a split of two different keys, but it was much, much rarer. And when it did happen, I just deleted the output files and ran it again.

With the ability to scramble several different files with the same key easily, I realized I now had a way to fully expose the reordering that had been done on a grid. It works like this. Make one grid with all As. Make another grid with the first 25 letters replaced with B, C, D, on up to Z. Make a third grid with the next 25 letters replaced with B through Z. Make a fourth grid that replaces the next set of 25 letters, and so on until every square is set to something other than A in exactly one file. Scramble them all at once so they have the same key. Thanks to the additive nature of the encryption, you can compare each of the B-through-Z files with the all-As file to identify where each of the B-through-Z letters were reordered to.

AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
TSONVUQP
TSONVUQP
QPLKSRNM
QPLKSRNM
XTSAZVUY
XTSAZVUY
UQPXWSRV
UQPXWSRV
BJRZAAAA
CKSAAAAA
DLTAAAAA
EMUAAAAA
FNVAAAAA
GOWAAAAA
HPXAAAAA
IQYAAAAA
TNOJVBQF
TJOFVNQJ
QCLYSGNU
QYLUSCNY
XTYAWVSZ
XVSDZZUD
UQPXWSRV
TQPXWSRV

Thus, for example, looking at the two scrambled grids on the right, the Y in the middle of the rightmost column of the top grid is a Z in the second grid. A difference of 1 means that it must match the square that went from A to B in the unscrambled grid. The S at the top of the second column becomes an N in the next grid, for a difference of 21. This corresponds to the square that contains a V (i.e. the letter shifted 21 from A) in the unscrambled grid. And finally the U in the bottom left corner that becomes a T corresponds to the A that was replaced with Z.

BJRZIQYA
CKSBJRZA
DLTCKSAA
EMUDLTAA
FNVEMUAA
GOWFNVAA
HPXGOWAA
IQYHPXAA
TNOJJBFF
RJNFVNQJ
KCGYOGKU
GYCUKCGY
JGYAWVSZ
FVBDJZFD
YQUXCSYV
TQQXYSUV
BJRZIQYH
CKSBJRZI
DLTCKSBJ
EMUDLTCK
FNVEMUDL
GOWFNVEM
HPXGOWFN
IQYHPXGO
WNSJJBFF
RJNFWNSJ
KCGYOGKU
GYCUKCGY
JGYFWBSZ
FVBDJZFD
YCUKCGYC
TYQGYCUG

By scrambling enough grids simultaneously, I could figure out where every position in the original grid went to in the scrambled grid. (And it was necessary to scramble them simultaneously; I verified that grids assigned different four-digit keys were scrambled completely differently.)

So this meant that I could completely separate out the encryption and reordering steps. I cobbled together another script that would take a set of such files, locate all of the reordered letters, and then spit out the encrypted string in its unscrambled order, along with the scrambled ordering sequence, all in a single line of text. This had become easy enough to do that it was little effort to accumulate multiple examples of the same size grid scrambled with various keys. With this, I could then start looking more widely for patterns.

1228 EGAAZOUUNIONMGHTNNINGGHMF 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15
1462 HKKJHMMOLUSQNMTIMLSJRMTIM 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10
1849 LZPTMAFJCDAZWVUPKSZBWVUPO 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3
2415 KJINPSORNQLQMLFIMNLMKLHNL 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7
2439 QLMXTAUDRYMESZLSLPNUKNJXP 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8
2532 KMOKPRSOOOMILLKKJPMMIMJKJ 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17
2699 PTADTHHHXEADTHDKWEAEQBTWI 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23
3247 LMNPUSZXVPTPQKSRMORTNLPPM 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8
3461 NRQLKMJHGPOROSRNSOTJOMWNS 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15
3627 PROTQSXBYVSWSURPKONXSWMSK 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22
3719 QSOSOQYEAYUASAWYIOGCUAOYQ 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10
4312 IKEIJLKKOMLMNLKJNJKINKLJL 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5
4722 KUNPRPPPUSSNUPUPTROMMNKIM 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1
5338 SRTWQMRRTMTTXTYYVQOYTTTAV 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1
6174 AUZVYVQQJHKPTRSSRSAWRNSVW 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14
6561 TSYSXWXOWRRIRRXOWRXTYSOJO 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6
6699 BYEBBBEHBHHHBEEHBHHKEEEEY 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2
6956 AEWYWAZXZZCEHHDBBBXXYZWWB 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24
7216 XRVUBLQQVMPVAROPUGJPMNGWR 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8
8181 SSGZZSZZSLLELLZSSLSSGSZLS 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19
8241 SQUTWUYZAMIEMILKQJMOCQPIT 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6
8345 WURVTSPZXTPSTPOWWTSAGXZTA 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24 10 21 7
9436 APZWKWBYEUVUZSYZEUSTYTMWU 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16 2 13 24
9911 CUUMCUUEUUEMMKUCCKUCUCMUU 2 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 0 11 22 8 19 5 16

I stored my collected information in files like this. Each file was devoted to a specific grid size. (This one is of grids of size 25.) This made it easy to write scripts to iterate over the grids of a particular size, to search for specific patterns, or to verify hypothesized invariants, or just to display information for me to stare at. Any time I had a new idea, I could quickly produce a script to try it out.

The Reordering Process: A Working Hypothesis

It didn't take much looking before some patterns started to become clear in the reordering. I noticed that, typically, a letter in the grid would wind up about 16 positions away from the previous letter (in the original grid), wrapping around from the end to the beginning in the usual fashion. If you examine the numbers on the right in one of the lines in the sample of grids shown above, and pick a 0 on one of the above lines, and then count 16 entries from there, you'll find yourself on the 1. Count 16 again to get to the 2, and so on.

The pattern of intervals — or "strides", as I wound up calling them — wasn't obvious until I started focusing on grids larger than size 32, but once I did it leaped out. In fact, the most common stride was exactly 16, with 17 and 15 coming in a distant second and third place. Looking at more examples showed that the stride could range all the way from 7 to 30, but extreme examples never appeared more than once or twice in a given grid. Almost all of a grid's strides would be in the range of 14–18.

As I looked at a grids of various sizes to see if the pattern continued to hold, I found that the reordering behavior was different for even-sized grids and odd-sized grids. If the grid size was odd, then the stride was exactly 16, every time, reliably. Irregular strides only occurred in even-sized grids. I was surprised to see that the code was making a distinction like that, but in a way it makes a kind of sense. Because 16 is a power of 2, it will always be coprime with a odd number, and therefore a stride of 16 is guaranteed to visit every square in an odd grid. With an even-sized grid, you have to take at least one odd stride in order to avoid revisiting a square before the grid is filled.

In any case, I found it strange that the reordering of even grids was so much more complicated, but at least I could say that I had actually figured out one small piece of the puzzle.

(None of these patterns applied to the initial position, by the way. From what I could see, the first letter could go anywhere in the grid, with equal probability.)

Collecting Data: No Seriously, Script Everything

As I realized that I needed to collect grids scrambled with as many different keys as possible, I wrote scripts to automate more and more of the collection process. Eventually I had all of it scripted except for one part — namely, retrieving the four-digit key. The key was never output anywhere; it was simply displayed to the user in a message box. There wasn't a way to copy the key to the clipboard or anything like that. So, I would run scripts that would do everything up to the scrambling of the files, then I would read the displayed key and enter it on the terminal command-line (or, if some of the keys failed to match, abort and start over), and then the second set of scripts would grab the scrambled files, extract the grids, determine the reordering and store the information in the appropriate data file. I lived with this for a while, until I was forced to acknowledge that this just wasn't going to work for the amount of data that I wanted to collect. So … I started investigating OCR programs for Linux.

for w in `xdotool search --title 'across lite info' | tac` ; do xdotool windowactivate $w sleep 0.3 k=`xwd -id $w -silent | xwdtopnm --quiet | gocr - | sed -ne 'y/I/1/;s/ //g;s/.*keytounscrambleis\([1-9]\{4\}\).*/\1/p'` if test "${key:=$k}" != "$k" ; then test $quiet || echo Warning: inconsistent keys \($key vs $k\). >&2 unset key break fi xdotool key Return 2> /dev/null sleep 0.2 done

I found a very simple one called gocr that worked on the command line. It took a pixmap file as input and returned plain text on standard output. The venerable xwd utility has the ability to select the window to screenshot by window ID, which could be turned into a pixmap via one of the ImageMagick utilities, which gocr could then turn back into text.

(Side note: I don't hate GUIs per se. What I hate are GOUIs: graphical-only user interfaces. They are the real blight. The above snippet demonstrates one of the things I love about being a Unix programmer: even when faced with a needless GOUI, there is always some way to turn it back into a text-based interface. And then we are unstoppable.)

So: I now had a fully automated system that could collect scrambled grids without oversight. I couldn't use the computer for anything else while it was running, of course, since it depended on screenshots and simulated keyboard events. But in the morning I would set it running in an infinite loop, collecting grids of a specific size, and when I came home from work I would find hundreds of new examples in my data file. A veritable mother lode.

The Reordering Process: Visualizing Strides

Looking at the rows of raw numbers and hoping to notice a pattern was futile, I quickly realized. So I started thinking about how I could display them in ways that would make patterns show up more clearly. Since I was storing all the data in easy-to-parse text files, it was a simple matter to write a script that could display the contents in different ways.

The first thing I wanted to do was display the strides instead of the absolute positions. In order to pack the information more densely, I displayed the stride value as a single character in base 36 — i.e. A being 10, B being 11, C being 12, and so on. (The four-digit key is shown on the far left, and next to it is displayed the initial position in base 16.)

1117 3A UHGGGGGFGGGGGEHGGGGGFGGGGCJGGGGGGFGGGGEHGGGGGFGGGG8MHGGGGGFGGGGEHGGGGGGFGGGGEHGGGGGFGGGGGEHGGGGGFGGG
1544 14 OGKIHGGGGGFGGGGGFGGGGGFGGGGCIHGGGGGFGGGGGFGGGGGGFG8GGKJGGGGGFGGGGGEHGGGGGFGGGGCJGGGGGGFGGGGEHGGGGGFG
1936 59 NGGGKIHGGGGGFGGGGEHGGGGGFGGGGCIHGGGGGFGGGGGFGGGGGG7GGGGMHGGGGGFGGGGGEHGGGGGFGGGGCJGGGGGGFGGGGEHGGGGG
2172 1C GSGJGGGGGFGGGGGEHGGGGGFGGGCGJGGGGGGFGGGGGFGGGGGFGGG8KIHGGGGGFGGGGGFGGGGGFGGGGCGJGGGGGFGGGGGFGGGGGGFG
2746 55 FOGGKIHGGGGGFGGGGGFGGGGGGFGGGCIHGGGGGFGGGGGEHGGGGGF8GGGKJGGGGGGFGGGGEHGGGGGFGGGGCIHGGGGGFGGGGEHGGGGG
2882 45 GNGGGKGJGGGGGFGGGGGFGGGGGGFGGGCGJGGGGGFGGGGGEHGGGGG7GGGKGJGGGGGGFGGGGGFGGGGGFGGGCGIHGGGGGFGGGGGFGGGG
3147 0E GGSIHGGGGGFGGGGGEHGGGGGFGGGCIHGGGGGFGGGGGEHGGGGGFGGG8KJGGGGGGFGGGGEHGGGGGFGGGGCIHGGGGGFGGGGEHGGGGGGF
3921 47 GFOGGGKJGGGGGFGGGGGFGGGGGGFGGGGCJGGGGGFGGGGGEHGGGGGF8GGGGNGGGGGFGGGGGGFGGGGGFGGGGGFGGGGGGFGGGGGFGGGG
4312 04 GGGOMHGGGGGFGGGGGFGGGGGFGGGGGCJGGGGGFGGGGGFGGGGGGFGGG8GNGGGGGFG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GFG
9324 11 GGGGGFGGOKJGGGGGFGGGGGEHGGGGGFGGGGCJGGGGGGFGGGGEHGGGGGFGGG8GMHGGGGGFGGGGGFGGGGGFGGGGGEHGGGGGFGGGGGFG
9711 60 FGGGGGFGOGGNGGGGGGFGGGGGFGGGGGFGGGGGCJGGGGGFGGGGGFGGGGGGFG8GGGNGGGGGFGGGGGEHGGGGGFGGGGGFGGGGGFGGGGGG

G, representing 16, is clearly the most common value, as I already knew. But other than that, it's hard to see much of anything. You can tell that the non-G values are roughly lining up in places, but that's about it. Obviously, this wasn't the right way to visualize my data.

My next thought was to use color to highlight values. Part of me disliked having to use colorized output, because it pretty much makes it impossible to pipe the output to anything else: it makes the program an endpoint of any pipeline. But I was desperate, so I did it anyway. This time, instead of displaying the stride's absolute value, I displayed the stride's offset from 16. I chose to display a positive offset in bright blue, and a negative offset in magenta. Zero would be displayed in dark blue, so that the non-zero values would stand out.

Immediately I knew that, whatever problems it introduced, colorizing the output was the right thing to do.

1117 3A E100000100000210000010000430000001000021000001000086100000100002100000010000210000010000021000001000
1544 14 8042100000100000100000100004210000010000010000001080043000001000002100000100004300000010000210000010
1936 59 7000421000001000021000001000042100000100000100000090000610000010000021000001000043000000100002100000
2172 1C 0C03000001000002100000100040300000010000010000010008421000001000001000001000040300000100000100000010
2746 55 1800421000001000001000000100042100000100000210000018000430000001000021000001000042100000100002100000
2882 45 0700040300000100000100000010004030000010000021000009000403000000100000100000100040210000010000010000
3147 0E 00C2100000100000210000010004210000010000021000001000843000000100002100000100004210000010000210000001
3921 47 0180004300000100000100000010000430000010000021000001800007000001000000100000100000100000010000010000
4312 04 0008610000010000010000010000043000001000001000000100080700000100000210000010000010000001000001000001
4581 3F 0018040300000100000010000010004030000001000001000001080040300000100000100000010004030000010000021000
4759 2B 0007004210000001000021000001000402100000100002100000090004210000010000201000001000421000001000002100
4816 39 0018000610000010000210000010000021000001000001000000180006100000100000210000010000430000001000021000
4915 33 0007000610000010000021000001000043000001000002100000180000700000010000210000010000021000001000001000
4988 11 0008100402100000100000210000010040210000001000021000080100402100000100002100000100040210000010000210
5596 21 0000704021000001000002100000100400300000010000210000018004021000001000021000001000402100000100000100
5738 25 0001800421000001000021000000100042100000100000210000018000610000001000021000001000042100000100002100
6147 43 00100C2100000100000210000010004210000010000021000001000843000000100002100000100004210000010000210000
6165 3F 00100C0300000100000210000010004030000001000021000001000842100000100000100000010004210000010000021000
6673 17 0000180042100000100000100000010004030000010000021000001800403000001000002100000100040300000010000010
6911 1B 0000180007000000100000100000100000430000010000010000001800007000001000002100000100000100000100000010
6947 03 0000070004210000010000021000001000421000001000002100000810004300000010000210000010000421000001000021
7163 33 000100C030000010000021000001000403000001000002100000100084300000010000010000010000421000001000001000
7356 21 0000108421000001000002100000100040300000010000210000010080421000001000021000001000042100000100000100
7529 17 0000108042100000100002100000010004210000010000201000001080061000001000002100000100002100000010000210
8381 0F 0000010840300000100000010000010004030000001000001000001008040300000100000100000010004030000010000021
8421 1F 0000100807000001000000100000100000100000010000010000010008043000001000001000000100004300000100000210
8583 5E 1000001804030000001000001000001000402100000100000100000018004030000010000021000001000403000001000002
9312 19 0000100086100000100000100000100000430000010000010000001000807000001000002100000100000100000010000010
9324 11 0000010084300000100000210000010000430000001000021000001000806100000100000100000100000210000010000010
9711 60 1000001080070000001000001000001000004300000100000100000010800070000010000021000001000001000001000000

I quickly began noticing patterns in the data. I realized that there was a "seam" of large positive numbers running down the left-hand edge, with values like +7, +8, and +12. And down the middle of the sequence list was a seam of large negative values, usually –8. No other numbers in the stride sequence went outside the range of ±5.

Going down the list, I noticed that the positive number seam slowly moved away from the edge, and that that the negative number seam moved at the exact same rate, so that they were always halfway across the sequence from each other. Closer inspection suddenly brought forth the realization: The position of the positive number seam was equal to the first digit in the key. So, a key of 2358 would mean that the maximum-width stride would be between the second and third square. No exceptions.

Furthermore, I saw that the largest positive values, +11 and +12, only occurred with keys with a second digit of 1. Any other second digit, and the big positive value stayed in the range +7 to +10, with another +4 somewhere nearby. Eventually I realized that the +12 was actually a separate +8 event and a +4 event that had coincided. There was another +4 event near the halfway point, not far away from the –8 event.

It appeared that the placement of these exceptions to the 16-stride rule was partly based on the size of the grid and partly based on the individual digits of the key. By looking at a larger grid size, I was able to see the individual events more clearly:

1318 44 86100000001000000210000000100000042100000001000000210000000100008061000000010000002100000001000000210000000100000021000000010000
1561 2E 80403000000010000000100000001000004030000000100000001000000010008004300000001000000010000000100000043000000010000000210000000100
2156 38 0C210000000100000021000000010000040300000001000000010000000100000842100000001000000210000000100000421000000010000002100000001000
2172 38 0C030000000100000001000000010000040300000001000000010000000100000842100000001000000210000000100000403000000010000000100000001000
2346 2C 08421000000010000002100000001000004210000000100000021000000010000804300000001000000010000000100000042100000001000000210000000100
3432 20 00806100000001000000210000000100000043000000010000000100000001000080430000000100000001000000010000004300000001000000010000000100
3626 0C 00800610000000100000021000000010000002100000001000000210000000100080043000000010000000100000001000000421000000010000002100000001
4296 00 00084021000000010000002100000001000040210000000100000021000000010008402100000001000000210000000100004003000000010000000100000001
4362 0C 00084030000000100000001000000010000040300000001000000010000000100008043000000010000000100000001000000421000000010000002100000001
4655 73 10080043000000010000000210000000100000421000000010000002100000001008004210000000100000021000000010000040300000001000000010000000
5217 0E 00008610000000100000021000000010000002100000001000000210000000100000861000000010000002100000001000000430000000100000002100000001
5519 73 10008061000000010000002010000000100000421000000010000002100000001000800610000000100000021000000010000002100000001000000210000000
5537 6F 01008042100000001000000210000000100000421000000010000002100000001000800610000000100000021000000010000004300000001000000021000000
5563 6B 01008040300000001000000010000000100000403000000010000000100000001000800430000000100000002100000001000004210000000100000021000000
5682 5D 00108004030000000100000001000000010000040300000001000000010000000100800403000000010000000100000001000004021000000010000002100000
5781 57 00108004030000000100000001000000010000040300000001000000021000000010800040300000001000000010000000100000403000000010000000100000
5936 51 00108000421000000010000002100000001000004210000000100000021000000010800006100000001000000210000000100000043000000010000000100000
5975 43 00018000403000000010000000210000000100004021000000010000002100000001800004210000000100000021000000010000040300000001000000010000
6264 71 10000842100000001000000210000000100000421000000010000002100000001000084030000000100000001000000010000040300000001000000010000000
6645 57 00100800430000000100000001000000010000004300000001000000021000000010080042100000001000000210000000100000421000000010000002100000
6794 3D 00001800402100000001000000210000000100004003000000010000000100000001080004030000000100000001000000010000040210000000100000021000
7252 69 01000084300000001000000010000000100000043000000010000000100000001000008421000000010000002100000001000004030000000100000001000000
8376 41 00010008402100000001000000210000000100004021000000010000002100000001000804210000000100000021000000010000040300000001000000010000
8729 2F 00000108004210000000100000021000000010000042100000001000000210000000100800061000000010000002100000001000000210000000100000020100
9421 47 00010000807000000010000000100000001000000010000000100000002100000001000080430000000100000001000000010000004300000001000000010000
9548 29 00000100804210000000100000021000000010000042100000001000000210000000100080042100000001000000210000000100000421000000010000002100
9581 27 00000100804030000000100000001000000010000040300000001000000021000000010080040300000001000000010000000100000403000000010000000100
9634 2D 00000100800610000000100000021000000010000004300000001000000010000000100080043000000010000000100000001000000421000000010000002100
9782 15 00000010800403000000010000000100000001000004021000000010000002100000001080004030000000100000001000000010000040300000001000000010
9895 03 00000001800040300000001000000021000000010000402100000001000000210000000180004021000000010000002100000001000040030000000100000001

I now could see that there was a consistent pattern of one +8 event, two +4 events, four +2 events, and eight +1 events. These were balanced by an equal number of negative events, offset for maximum distance from the matching positive events, more or less. And the events could overlap each other, in which case they would just add together, like waves passing through each other.

I found myself imagining the underlying mechanism using physical imagery. Specifically, I imagined the four digits of the key as being like four timing wheels that would turn with each step of the reordering process, periodically firing to create the positive and negative changes in the stride. I therefore wound up referring to the events as "firings". The +8 and –8 wheels fire once, the ±4 wheels fire twice, etc.

I labelled the four separate digits of the key a, b, c, and d, and set out to create formulas that gave the location of every firing. The +8 firing occurred at position a. The –8 firing could be expressed as a + N/2 (where N stood for the size of the grid). The +4 mechanism produced two firings, and it didn't take long to determine that they took place b/2 positions after the ±8 firings. Although if b was odd, then the second firing would actually be at (b + 1)/2. Or, put another way, the value was (b + i)/2, where i was 0 or 1 depending on the firing. (Note that the slash specifically represents integer division, where any remainders are discarded.)

The two –4 firings proved to be a little more complicated, but not intractable. Encouraged by these results, I dove headfirst into the ±2 and ±1 firings. When I was done, I had this:

F+8= a
F–8= a + N/2
Fi+4= F±8 + (b + i)/2
Fi–4= F±8 + (b + (N/2)%2 + i)/2
Fi+2= F±4 + (c + (2·(b%2) + i·(2·((N/2)%2) + 1))%4)/4
Fi–2= F±4 + (c + (N/2)%4 + (2·(b%2) + i·(2·((N/2)%2) + 1))%4)/4
Fi+1= F±2 + (d + (2·((2·(b%2) + c)%4) + i·(N%8 + 1))%8)/8
Fi–1= F±2 + (d + (N/2)%8 + (2·((2·(b%2) + c)%4) + i·(N%8 + 1))%8)/8

As you can see, it got a lot uglier pretty quickly. And I'm skipping over a bunch of time here. There were a few failed attempts, that only worked some of the time, and there were formulas that were much more complicated than these. But this was the first set of formulas that accurately predicted the reordering of every single grid of size 128 that I had collected so far. I then tried it on a larger grid size, size 140, and again it correctly predicted every single one. I also tried it on a smaller grid size, size 122 — and it got exactly one grid wrong, in one place.

I wanted to cry.

But this wasn't an anomaly. The more I looked at the smaller grids, the more divergences I found from my model. By focusing on the larger grid, I had apparently not been able to see some further set of complications to my model. Not that this model was simple, mind you. But apparently it was still too simple. After all, it did work consistently for larger grids. That couldn't be accidental. So the fact that it worked sometimes but not all the time seemed to indicate that the real answer was more complicated still.

In parallel with this, I had been trying to figure out how the initial position was selected. Since that was just a single number, it was a little easier to explore. I looked for scrambled grids where the keys differed from each other by only one number, and could see some obvious patterns. In fact, I soon realized that, once again, the odd-sized grids followed a relatively simple rule:

IP = 15 2·(8a + 4b + 2c + d) % N

But even-sized grids followed a slightly more complicated rule, one that usually produced similar results, but with occasional disruptions. (Sound familiar?)

IP = 2·(8a + 4b + 2c + d)
parity = 1
while IP < 0
IP += N
parity = 1 parity
IP += parity

Oh and also when I tried to apply the rule to smaller grids, I found more exceptions where these rules stopped working.

Interlude: Epicycles

At this point, I felt like I was inventing epicycles. Are you familiar with epicycles? They were circles-upon-circles that earlier astronomers theorized to explain the motion of the sun, moon, and planets — specifically to explain why they periodically sped up and slowed down, even to the point of going backwards at times. I mean, if they were rotating at constant speed in perfect circles, how could there be all these variations? Epicycles were the theory that the celestial bodies were really attached to a secondary circle that rotated around the point of attachment to the main circle. A slight complication to the original picture. It did a great job of explaining the orbit of the sun and moon, for example. But when you applied the same approach to the planets, this simple model isn't quite enough. More epicycles are needed, but also things like deferents and equants. In the end the (known) solar system requires dozens of epicycles to cover all the observed motions.

Despite the complexity, this system did a pretty good job of predicting the motion of the heavenly bodies. But even so, there were hints that it wasn't the right answer. For example, all the planets have completely independent motions, yet why do the orbits of the two fastest planets, Mercury and Venus, never take them very far away from the position of the sun? Under the epicycle model, this could only be considered a coincidence. Like the Ptolemaic astronomer, I found myself unable to explain certain features of my stride equations. You'll notice that certain terms, like 2·(b%2), crop up in several places, while most terms only appear once. That suggests that there's something in there that hasn't been factored out correctly. But there's something else that's much more troubling. Would you guess, just from looking at these equations and knowing how they're used to guide the reordering step, that it would always assign exactly one letter to every position in the output, never accidentally trying to put two letters into the same position? I mean, it just so happens to be true — but it's far from obvious. Usually when a sensible person writes something like a reordering algorithm, a necessary feature like that will usually be a clear feature of the code.

Things like this convinced me that what I had created was an effective system of epicycles. But then the next question was: how do I go from epicycles to ellipses? If this system of stride formulas isn't the right answer, then how do I get from here to a better answer?

Of course, during this time I wasn't just looking at the reordering process. There was also the actual encryption. I worked on both in parallel, so that when I got frustrated with one I would switch over to the other. So, let's set the reordering problem aside for now, rewind a bit, and cover the other half of the scrambling process.

The Encryption Process: Various Visualizations

Remembering how color had helped me to see patterns in the reordering process, I started by writing scripts to colorize the encrypted grids in various ways, looking for an entry point. One of the first I tried was to color each letter based on how distant it was from the previous letter in grid.

1117 KQKKKKEKQKEKQKKKEQKKKKKEKQEKQKKEKKKQKKKKKKKEQQKEKQEKQEKKKKEKKKQEKQKKKKEKQKKKQKKKEQKKKKKEEQKKKKKEKKEQ
1544 SKOOKTLNQLSOMNOTOLQPKRQN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IQQTRZRMSRANKYTTOLXOUVJSQVVIRYWRGLSSPXQKTVZOMQRUNRYQTXLUOJX
7356 AUTWXXXRQZWVUTYTZXMAVXVPVSVYUXWTXWRTZAVTTXTXUQAWXUPYVZYMXVTVUVTVAUTWSXXRXZWVWTYTAXMAXXVPZSMYVXVTVWVT
7529 ILVVXEUZYCCPTCSYBXNXAWXSZWEBLEVZEQVRCIPVCXCUXYXCWTNSWBBNEAEXQZREILZVXEUZYCZPTCRYBXCXTWSSBWNBAEXZZQER
8381 IWSZWGWUSUGWNSUGPPBSBPNBNBZPWLZBGWUZUIWSSWGWPSSGPNBUBPPBLBZNWNZZIWBZWGPUSUBWNSZGPPSSBPWBNBGPWLUBGWZZ
8421 OIQMCIIWIWWFMLWTHSMQSEJPVPAPIPMGILWJWOFQLCTISIQWEMPWPHPMPSAJLVJAOIWMCIIWIWTFMLWTHSPQSEJPVPWPIPWGILAJ
8583 DVTDTDBVARBDOAYBYQAWWAGAVWWGVTDYDVVDRDBTATBBQAYBAOAYWYGATWYGVVWWDVADTDGVARYDOADBYQTWWABAVWBGVTGYVVWD
9312 SVQFORORVNMWPNPLPQPOEXQHXMJRVWFRRNRNNSWQNOLOQVOMXPHPMPRPWERQNXNJSVQFNRORVNMWQNPLPQPOMXQHXMJRPWFRXNJN
9324 RYNZZKROLYTSPSTMSWNSFTJUMYUQYLZVKXOSYRSNSZMRWLSTTPUTYSQNLFVJYMSURYNZYKROLYTSWSTMSWNSZTJULYUQFLJVMXUS
9711 EYYMYMMEUSMSWMYUMCASKSMSYSUEYSMAMQEUSEMYMYUMCUYMSWSYSMMASKAMQYMUEYYMYMSEUSMSWMSUMCASKSESYSUEYSYAMQUU

Red for closest, violet for most distant. Since the plaintext letter is always A, any variance or pattern from letter to letter should be entirely due to the encryption process. Note, however, that this display is showing the grids as they appeared in the scrambled output file. In contrast, here is the same colorization filter applied to the encrypted grids after undoing the reordering step:

1117 EEKKKEKKKEKKKEKKKEKKKEKKKEKQQKQQQKQQQK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YZABYZABVWXYVWXYVWXYUYZAXYZAXYZAXV
7163 AVZXAVZLRGNIOGNIOGNIOJQLRJQLRJQLYQRMSKRMSKRMSKXSYQXSYQXSYVVQTOSQTOSQTOSQWRVTWRVTWRVXUPTRUPTRUPTRUVZX
7356 WUUXWUUVXMRPTMRPTMRPTMVTXQVTXQVTXSXWATYWATYWATYVZSXVZSXVZUUAVTTWVTTWVTTWZXXAZXXAZXXAWVVYXVVYXVVYXVUX
7529 SVNZSVNCERZCEYZCEYZCEYSVXRSVXRSVXRZACWXACWXACWXCEYZCEYZCEVNZBEWIBEWIBEWIBXPBUXPBUXPBUTLXQTLXQTLXQTNZ
8381 GBGZGBGZBPWGPIPGPIPGPIPGWPWNWPWNWPBSWPWNWPWNWPWNWUBSBUBSBUGZZUSLSNSLSNSLSNZSZUZSZUZSZBGUBWBUBWBUBWBZ
8421 GWATGWATWPIEOHIEOHIEOHIFPIJFPIJFPIJISLMISLMISLMIWPQMWPQMWPATWLPIVLPIVLPIVMQJWMQJWMQJWWWPCSWPCSWPCSAT
8583 GDGBGDGBDYATVQVOVQVOVQVOVVATAVATAVAWDVATAVATAVATAVDWDYDWDYGBGYBRWTWRWTWRWTWWBYBWBYBWBYGBDADYDADYDADY
9312 MOENMOENMQJLRMJLRMJLRMJRXSPRXSPRXSPPWROQWROQWROQVQNPVQNPVQNNMRHQPRHQPRHQPXNWVXNWVXNWVXFONPFONPFONPFN
9324 WXPYWXPYWYLOUNNOUNNOUNNMSLLMSLLMSLLZZSSTZSSTZSSTFYYZFYYZFYYYWUMVTUMVTUMVTUKTRSKTRSKTRSJSQRJSQRJSQRJY
9711 MSEMMSEMMYMSYCQWYCQWYCQWYESYAESYAESYAYMSUYMSUYMSUYMSUYMSUYMMMSESSYKSSYKSSYKUUAMUUAMUUAMUMSEMMSEMMSEM

As you can see, there is much more suggestion of pattern here, with short columns of colors as patterns align across grids. I had originally guessed, just as a hunch, that the encryption step came first, followed by the reordering step. This output seemed to confirm that my hunch was correct.

I also couldn't help noticing that a few of the entries had long sections of red, and that they happened to be entries with repeated digits in the key. So I tried an experiment where instead of sorting my grids by the key's numerical order, I sorted it so that keys with digits that were close together came earlier than keys with widely varying digits.

4312 KGHFMLKKNLKKNLKKNLLLOMLLOMLLOMJKNLKKNLKKNLKJMKJJMKJJMKHFNJKINJKINJKIOKLJOKLJOKLJOHIGLHIGLHIGLHHFKGHF
1544 KMKSOTRSOTRSOTRSOTRSOTRSOTRSHQOPLQOPLQOPLQKLHMKLHMKKKLQNNOQNNOQNNOQNNOQNNOQNNOQKOPROOPROOPROKLNKKLNK
6673 ZAAXZABUASWPVSWPVSWPVSWPVSWPVSWPVSBUWTXQWTXQWTXQAXBUAXBUZAAWYZZWYZZWYZZWYZZWYZZWYZZWZAWTVWWTVWWTVWWX
5596 GCKDGYDVVUZVVUZVVUZVVUZVVUZVVUZVZYDWWVAWWVAWWVAZZYDZZYDDGCDWZVDWZVDWZVDWZVDWZVDWZVDDGZHADZHADZHADZKD
7356 WUUXWUUVXMRPTMRPTMRPTMVTXQVTXQVTXSXWATYWATYWATYVZSXVZSXVZUUAVTTWVTTWVTTWZXXAZXXAZXXAWVVYXVVYXVVYXVUX
4988 UDYCVZZYEIIHEIIHEIIHEIIHEIIHEIIHEZZDAEEDAEEDAEEDVZZYVZYCUDYGYHCGYHCGYHCGYHCGYHCGYHCGUDDHZIDHZIDHZIYC
6165 YTYXYTORNMNQNMNQNMNQONORONORONOWTNORONORONOROSTWTSTWTSTWYSWVWRWVWRWVWRWWXSXWXSXWXSYSTOTSTOTSTOTSYTYX
6947 WXUVWXZABCAEFGDEFGDEFGDECDABCDABCDAAEFCDEFCDEFCDECZABCZAWXUVWYYZABYZABYZABVWXYVWXYVWXYUYZAXYZAXYZAXV
2746 KRPQNYYZWAYZWAYZWAYXUYWXUYWXUYPVSWUVSWUVSWUVNRPQNRPQKRMQOXSWQXSWQXSWQVQUOVQUOVQUORRVPWRVPWRVPWMQKRMQ
4759 SWTYUZVDZEAGZEA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UYMSUYMSUYMSUYMMMSESSYKSSYKSSYKUUAMUUAMUUAMUMSEMMSEMMSEM

This output confirmed that general pattern, with red colors at the top slowly shifting across the spectrum into more blue and violet colors at the bottom.

Perhaps the most striking example was a single grid I had managed to find in which the key was 8888 — a single repeated digit. The scrambled grid for this key was all Gs. That suggested a number of possible underlying mechanisms for the encryption process, which unfortunately proved not to hold up. For example, you might naively expect that a key of three repeated digits might tend to have three out of every four letters be identical, but this was not the case. (Although such grids did tend to have a lot of repeated letters, demonstrating that this idea likely wasn't entirely wrong, just oversimplified.)

Still, you can see that there does seem to be an erratically recurring rhythm of fours in the grids. With the key being four digits long, there was definitely an attraction to the idea of the encryption process being based on a cycle of four steps, rotating through the digits of the key in some way or another. I found myself imagining a series of rotors, sort of like parts of the Enigma machine, for those of you who've read about that.

So the next colorizing display I tried out specifically indicated when a sequence of four letters was repeated.

1117 EEKKKEKKKEKKKEKKKEKKKEKKKEKQQKQQQKQQQKQKKEKKKEKKKEKKKKKQKKKQKKKQKKKQKKKQKKKQKKKQKKKQKKKQKKEKEEEKEEEK
1544 KMKSOTRSOTRSOTRSOTRSOTRSOTRSHQOPLQOPLQOPLQKLHMKLHMKKKLQNNOQNNOQNNOQNNOQNNOQNNOQKOPROOPROOPROKLNKKLNK
1936 KWNTLCBHZKBHZKBHZKTZRCTZRCTZRCNWOZQWOZQWOZQWLWNTLWNNKQMNTZVWTZVWTZVWTRNOLRNOLRNOLQPQNTPQNTPQNTMNKQMN
2172 SWLHFFKGFFKGFFKGGGLHGGLHGGLNMHMIHHMIHHMIHHRNMMRNMMRNSMMMHLMMHLMMHLMNIMNNIMNNIMXXNRSSNRSSNRSSSWXXSWXX
2746 KRPQNYYZWAYZWAYZWAYXUYWXUYWXUYPVSWUVSWUVSWUVNRPQNRPQKRMQOXSWQXSWQXSWQVQUOVQUOVQUORRVPWRVPWRVPWMQKRMQ
2882 IUAOUUAOOOUIOOUIOOUIUUAOUUAOUUAOUAGUAAGUAAGUAUAOUUAOI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PCSWPCSAT
8583 GDGBGDGBDYATVQVOVQVOVQVOVVATAVATAVAWDVATAVATAVATAVDWDYDWDYGBGYBRWTWRWTWRWTWWBYBWBYBWBYGBDADYDADYDADY
9312 MOENMOENMQJLRMJLRMJLRMJRXSPRXSPRXSPPWROQWROQWROQVQNPVQNPVQNNMRHQPRHQPRHQPXNWVXNWVXNWVXFONPFONPFONPFN
9324 WXPYWXPYWYLOUNNOUNNOUNNMSLLMSLLMSLLZZSSTZSSTZSSTFYYZFYYZFYYYWUMVTUMVTUMVTUKTRSKTRSKTRSJSQRJSQRJSQRJY
9711 MSEMMSEMMYMSYCQWYCQWYCQWYESYAESYAESYAYMSUYMSUYMSUYMSUYMSUYMMMSESSYKSSYKSSYKUUAMUUAMUUAMUMSEMMSEMMSEM

In this display, the bland cyan is the background color. Green shows when a sequence of four letters is repeated once. Magenta indicates a "three-peat", i.e. another repetition, followed by yellow, then red, and so on. Once again, we see that there are vague patterns occurring across grids, and roughly moving towards the right as the digits in the key get larger.

However, what eventually caught my eye in this display was the stumpy little column of green down in the lower left. It surprised me because unlike the other patterns, it was exactly vertical, straight up and down. And so close to the left edge, it showed that these grids had a repeating pattern of four right from the start.

Upon studying this anomaly more closely, I realized that the column began right when the leftmost digit of the key increased to 8. Looking at the first eight letters of grids with a key starting with 7 showed that they repeated three of the first four letters, but then the last letter invariably diverged. And likewise, keys starting with 6 suggested that they had the repeating-fours pattern as well, but interrupted after the sixth letter in the grid. Even more exciting, I noticed that when the key started with 4, then first four letters of the grid was repeated at the end of the grid.

Based on these observations, I theorized that this "quartet" encryption pattern actually ran all the way through the grid, from beginning to end. Mostly it was obscured with another layer of encryption, but it was visible along the leftmost edge, as long as the first digit of the key was greater than or equal to 4. I further theorized that if I isolated the underlying quartet pattern, I could subtract it out of the encrypted grid, and hopefully what remained would be simplified as a result. So instead of thinking of rotor wheels, I began to imagine the encryption process as a set of layers, each one applied in turn atop the other.

If I could completely associate the pattern of the underlying quartet to the four-digit key (and possibly the grid size), that would be a real milestone. In order to do that, I needed more data.

Interlude: Epicycles, Revisited

A while ago I drew comparisons with the my reordering model and the Ptolemaic system of planetary orbits, and I asked rhetorically, how does one go from epicycles to ellipses? I mentioned some of the facts that hinted at the incompleteness of the older model — Mercury and Venus, and the fixed stars — but really those were hints that the the geocentric model was wrong. Those hints led to the heliocentric model, but heliocentrism alone doesn't actually get rid of epicycles. You still need them to match the orbits of the planets, because you're still using circles for everything. In fact when Nicolaus Copernicus advanced his heliocentric system, he required more epicycles, not fewer, because he used them instead of equants, which geocentrism made necessary. Copernicus advocated for heliocentrism in part because it explained the aforementioned coincidences, but mainly because it allowed him to get rid of the equant points, which were hard to calculate with and, in Copernicus's opinion, aesthetically ugly. They sullied the perfection of the circles.

But if you're looking to ditch epicycles — if you want to make the leap to elliptical orbits, as Johannes Kepler did — those facts aren't enough. So: what did Kepler have that Copernicus didn't, that led him to leave circles behind completely, and consider a completely different model in search of simplicity? Probably more than anything, he had Tycho Brahe's data. Tycho Brahe compiled some of the most precise and thorough astronomical observations made before the invention of the telescope. It was by studying his numbers, and the story that they told, that Kepler could see the flaws in even the best epicyclical model, and was forced to abandon that system entirely, and to finally consider the possibility of orbits in the shape of imperfect, lopsided ellipses.

Collecting Data: Time For A New Approach

Like Kepler, I needed more data. In particular, I was now occasionally wanting to see the grid for a specific key. For example, I had noticed that most of the grids where my reordering algorithm failed were ones that had 1 or 2 for the first digit and 8 or 9 for the remaining digits. But I only had a few example of these. I needed more of them to see if this pattern held, or if it was just a coincidence. In order to do that, I either had to be extremely patient, or I had to figure out how to control which four-digit key was selected. Knowing that it was somehow related to the current time, I sat down and started doing some experiments. And in very little time I worked out the exact process by which the key was selected:

  1. Take the current Unix time as a decimal number.
  2. Read the digits from right to left.
  3. Skip over the first (lowest) digit, and any zeros.
  4. Stop once four digits have been obtained.

For example:

time(0) =
12188680959868

So now I knew how to pick a current time in order to get Across Lite to use a specific key. I could have set the computer clock just before scrambling a grid, but of course there's a much easier way. You've probably already heard of Unix's LD_PRELOAD environment variable. By providing a path to a shared-object library in this variable, you can force it to be loaded ahead of any other dynamic libraries when a program is run — even before system libraries like libc. It's sometimes used to replace malloc() et al. with debugging versions, but a very common use, at least at one time, was to change the system time for a single program, typically demo programs that were set to expire at the end of some trial period. Some poking around online and I quickly found sample code that showed how to create a library that provided a replacement gettimeofday() system call. With the help of LD_PRELOAD, I set it up so that this library was feeding the current time to my wine process, and thus by extension to the Across Lite windows program.

(Interesting aside: My first version of this library simply always returned the same time every time it was invoked, but to my surprise this caused the Across Lite program to malfunction, producing a negative value for the scrambling key. So I then tried just having my library set the initial time, but then count time normally afterwards. However, wine could sometimes be slow to initialize, and I found that starting too many wine processes simultaneously could cause one of them to crash, presumably due to some race-condition bug. So finally I modified my library so that it advanced the clock one microsecond every time gettimeofday() was invoked, and that worked perfectly. I also discovered that just starting a single wine process running Across Lite and then immediately shutting it down caused gettimeofday() to be invoked over 3000 times.)

Since I was already making changes to how I collected my data, I took this opportunity to do a major overhaul on the central process. As proud as I was of my Rube Goldberg solution of cobbled-together scripts and obscure utilities, it really was a very complicated solution. I have some experience with Windows code, and I knew that a Windows program would be able to handle all of the interactions with the Across Lite application, and it would be able to do so in a much more direct manner, for example not having to use OCR in order to read the text in a message box.

HWND wnd = NULL; int counter = 0; for (;;) { wnd = FindWindowEx(NULL, wnd, AL_WINDOW_CLASS, NULL); if (!wnd) break; char buf[AL_WINDOW_TITLE_PREFIX_LEN + 1]; GetWindowText(wnd, buf, sizeof buf); if (strcmp(buf, AL_WINDOW_TITLE_PREFIX)) continue; if (!PostMessage(wnd, WM_COMMAND, AL_IDM_SCRAMBLE, 0)) { warn("PostMessage to window %04X: %s", wnd, GetLastError()); ++failures; break; } ++counter; }

Here's a brief sample from the C program I wrote, which selects the "scramble" menu command on all running instances of Across Lite. Not only was this simpler, it was also more reliable, and quite a lot faster.

Armed with my Windows program and my time-setting script, I set up a new data collection process. Now, instead of just fishing for grids at random, my scripts specifically gathered grids that weren't already in my collection. And this turned out to be extremely important. Because once I had long stretches of adjacent keys, I finally was able to see the patterns is explicit detail.

The Encryption Process: Layers Upon Layers

Here's an example of what some of the new data looked like:

7581 EBFXEBFUWXWMOQPMOQPMOQPMVXWTVXWTVXXUUWVSUWVSUWVSUYXUWYXUWBFXYVSKROSKROSKROZRYVZRYVZRYBFVCZDVCZDVCZDX
7582 EBFYEBFVXXXOQRROQRROQRROWXXUWXXUWXYVVWWTVWWTVWWTVYYVXYYVXBFYZWUNTQUNTQUNTQATZWATZWATZBFWCZDWCZDWCZDY
7583 EBFZEBFWYXYQSSTQSSTQSSTQXXYVXXYVXXZWWWXUWWXUWWXUWYZWYYZWYBFZAXWQVSWQVSWQVSBVAXBVAXBVABFXCZDXCZDXCZDZ
7584 EBFAEBFXZXZSUTVSUTVSUTVSYXZWYXZWYXAXXWYVXWYVXWYVXYAXZYAXZBFABYYTXUYTXUYTXUCXBYCXBYCXBBFYCZDYCZDYCZDA
7585 EBFBEBFYAXAUWUXUWUXUWUXUZXAXZXAXZXBYYWZWYWZWYWZWYYBYAYBYABFBCZAWZWAWZWAWZWDZCZDZCZDZCBFZCZDZCZDZCZDB
7586 EBFCEBFZBXBWYVZWYVZWYVZWAXBYAXBYAXCZZWAXZWAXZWAXZYCZBYCZBBFCDACZBYCZBYCZBYEBDAEBDAEBDBFACZDACZDACZDC
7587 EBFDEBFACXCYAWBYAWBYAWBYBXCZBXCZBXDAAWBYAWBYAWBYAYDACYDACBFDEBECDAECDAECDAFDEBFDEBFDEBFBCZDBCZDBCZDD
7588 EBFEEBFBDXDACXDACXDACXDACXDACXDACXEBBWCZBWCZBWCZBYEBDYEBDBFEFCGFFCGFFCGFFCGFFCGFFCGFFBFCCZDCCZDCCZDE
7589 EBFFEBFCEXECEYFCEYFCEYFCDXEBDXEBDXFCCWDACWDACWDACYFCEYFCEBFFGDIIHEIIHEIIHEHHGDHHGDHHGBFDCZDDCZDDCZDF
7591 IEKAIEKWYWWQSUUQSUUQSUUQUWWSUWWSUWAWYSS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TSWNTSWNTSVMSRVMSRVMSRBRXWARXWARXWASY
7624 XBSZXBSTUVOSTUOSTUOSTUOQRSMQRSMQRSMSTUOSTUOSTUOSUVPTUVPTUBSZRXOVTXOVTXOVTVMTRVMTRVMTRBRYWARYWARYWASZ
7625 XBSAXBSUVVRVWWRVWWRVWWRSTTOSTTOSTTOTUUPTUUPTUUPTVVQUVVQUVBSARYPXUYPXUYPXUVMURVMURVMURBRZWARZWARZWASA
7626 XBSBXBSVWVUYZYUYZYUYZYUUVUQUVUQUVUQUVUQUVUQUVUQUWVRVWVRVWBSBRZQZVZQZVZQZVVMVRVMVRVMVRBRAWARAWARAWASB
7627 XBSCXBSWXVXBCAXBCAXBCAXWXVSWXVSWXVSVWURVWURVWURVXVSWXVSWXBSCRARBWARBWARBWVMWRVMWRVMWRBRBWARBWARBWASC
7628 XBSDXBSXYVAEFCAEFCAEFCAYZWUYZWUYZWUWXUSWXUSWXUSWYVTXYVTXYBSDRBSDXBSDXBSDXVMXRVMXRVMXRBRCWARCWARCWASD
7629 XBSEXBSYZVDHIEDHIEDHIEDABXWABXWABXWXYUTXYUTXYUTXZVUYZVUYZBSERCTFYCTFYCTFYVMYRVMYRVMYRBRDWARDWARDWASE

Since I now had every single key value in sequence, I introduced a different coloring process. Here, the colors of each letter indicates its relationship with the same letter in the previous grid. Cyan indicates a letter that's the same as the one above it. Green marks a letter that's exactly one after the one above it. Yellow if it jumps by two, magenta if jumps by three. Dark blue if it appears to be unrelated. The grids making those dark blue dividing lines correspond, as you can see, to the points where the rightmost digits rolls back from 9 to 1, and the second-to-last digit increments.

Look at this. It's abundantly clear here, that when only the rightmost digit is changing, you can easily see its effect. And the effect remains consistent as long as the other digits are consistent. (The effect is not the same regardless of the other digits, though. It's not quite that simple.)

Anyway, the original motivation for collecting such complete data was trying to study the "underlying quartet" pattern. With this extra data, all it took was a single all-nighter, and I managed to work out the formulas that completely described the underlying quartet for all grid sizes.

if N%4 == 0 or 1:
z = a·(2 b%2 c%2) + c·(0 + b%2 + c%2)
else if N%4 == 2 or 3:
z = a·(0 + b%2 + c%2) + c·(2 b%2 c%2)
 
then, if N%4 == 0 or 3:
q0 = z + a·(2 a%2) + c·(0 + a%2)
q1 = z + a·(0 + a%2) + c·(1 a%2) + b
q2 = z + a·(1 a%2) + c·(1 + a%2)
q3 = z + a·(0 + a%2) + c·(1 a%2) + d
else if N%4 == 1 or 2:
q0 = z + a·(1 + a%2) + c·(1 a%2)
q1 = z + a·(1 a%2) + c·(0 + a%2) + b
q2 = z + a·(0 + a%2) + c·(2 a%2)
q3 = z + a·(1 a%2) + c·(0 + a%2) + d

Plugging in the grid size for N and the four digits of the key for a b c d, this spits out four numbers which consistently matched the underlying quartet for all grids that I could examine.

8891 HIIBHIIBIBJUZSALZSALZSALZSALZSALZSALZSALZSALIBBMATBMATBMATBMATJUIBJUIBJUHIIBGHHAGHHAGHHAGHHAGHHAGHHAGHHAGHHAHIITZAATZAATZAATZAAB
8892 HIICHIICICJWAUBOAUBOAUBOAUBOAUBOAUBOAUBOAUBOICCPBVCPBVCPBVCPBVJWICJWICJWHIICGHHBGHHBGHHBGHHBGHHBGHHBGHHBGHHBHIIVABBVABBVABBVABBC
8893 HIIDHIIDIDJYBWCRBWCRBWCRBWCRBWCRBWCRBWCRBWCRIDDSCXDSCXDSCXDSCXJYIDJYIDJYHIIDGHHCGHHCGHHCGHHCGHHCGHHCGHHCGHHCHIIXBCCXBCCXBCCXBCCD
8894 HIIEHIIEIEJACYDUCYDUCYDUCYDUCYDUCYDUCYDUCYDUIEEVDZEVDZEVDZEVDZJAIEJAIEJAHIIEGHHDGHHDGHHDGHHDGHHDGHHDGHHDGHHDHIIZCDDZCDDZCDDZCDDE
8895 HIIFHIIFIFJCDAEXDAEXDAEXDAEXDAEXDAEXDAEXDAEXIFFYEBFYEBFYEBFYEBJCIFJCIFJCHIIFGHHEGHHEGHHEGHHEGHHEGHHEGHHEGHHEHIIBDEEBDEEBDEEBDEEF
8896 HIIGHIIGIGJEECF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XIDDXIDDXIDDXCXXRCXXRCXXRCXXRCXXRCXXRCXXRWSRMWYXSCYXSCYXSCYXSCXWRBXWRBXWRBXWRBSRMWSRMWSRMWSRMWSRM
8934 WSRNWSRNCYXTIFEAJFEAJFEAJFEAJEDZIEDZIEDZIEDZCZYUDZYUDZYUDZYUDYXTCYXTCYXTWSRNWZYUDZYUDZYUDZYUDYXTCYXTCYXTCYXTCSSOXTSOXTSOXTSOXTRN
8935 WSROWSROCZXVIGECJGECJGECJGECJFDBIFDBIFDBIFDBCBZXEBZXEBZXEBZXEZXVCZXVCZXVWSROWAZWEAZWEAZWEAZWEZYVDZYVDZYVDZYVDSTQYUTQYUTQYUTQYURO
8936 WSRPWSRPCAXXIHEEJHEEJHEEJHEEJGDDIGDDIGDDIGDDCDAAFDAAFDAAFDAAFAXXCAXXCAXXWSRPWBAYFBAYFBAYFBAYFAZXEAZXEAZXEAZXESUSZVUSZVUSZVUSZVRP
8937 WSRQWSRQCBXZIIEGJIEGJIEGJIEGJHDFIHDFIHDFIHDFCFBDGFBDGFBDGFBDGBXZCBXZCBXZWSRQWCBAGCBAGCBAGCBAGBAZFBAZFBAZFBAZFSVUAWVUAWVUAWVUAWRQ
8938 WSRRWSRRCCXBIJEIJJEIJJEIJJEIJIDHIIDHIIDHIIDHCHCGHHCGHHCGHHCGHCXBCCXBCCXBWSRRWDCCHDCCHDCCHDCCHCBBGCBBGCBBGCBBGSWWBXWWBXWWBXWWBXRR
8939 WSRSWSRSCDXDIKEKJKEKJKEKJKEKJJDJIJDJIJDJIJDJCJDJIJDJIJDJIJDJIDXDCDXDCDXDWSRSWEDEIEDEIEDEIEDEIDCDHDCDHDCDHDCDHSXYCYXYCYXYCYXYCYRS

With this in hand, I wrote a filter script that would compute the underlying quartet for a key and then subtract it from the grid. This would then let me see what the remaining steps of the encryption looked like in isolation:

8891 AAAAAAAABTBTSKSKSKSKSKSKSKSKSKSKSKSKSKSKSKSKBTTLTLTLTLTLTLTLTLBTBTBTBTBTAA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JLJIGIGIGIGIGIAAAAAJJJJJJJJJJJJJJJJIIIIIIIIIIIIIIIIADDDDDDDDDDDDDDDDAA
8937 AAAAAAAAGJGJMQNQNQNQNQNQNQNQNPMPMPMPMPMPMPMPGNKNKNKNKNKNKNKNKJGJGJGJGJGJAAAAAKKKKKKKKKKKKKKKKJJJJJJJJJJJJJJJJAEEEEEEEEEEEEEEEEAA
8938 AAAAAAAAGKGKMRNRNRNRNRNRNRNRNQMQMQMQMQMQMQMQGPLPLPLPLPLPLPLPLKGKGKGKGKGKAAAAALLLLLLLLLLLLLLLLKKKKKKKKKKKKKKKKAFFFFFFFFFFFFFFFFAA
8939 AAAAAAAAGLGLMSNSNSNSNSNSNSNSNRMRMRMRMRMRMRMRGRMRMRMRMRMRMRMRMLGLGLGLGLGLAAAAAMMMMMMMMMMMMMMMMLLLLLLLLLLLLLLLLAGGGGGGGGGGGGGGGGAA

When I first saw this, I felt pretty good about myself. The resulting encrypted grids were clearly simpler with the underlying quartet removed. The remaining patterns appeared to be larger and slower to change, which made them easier to see and isolate. So I picked another pattern, came up with a set of formula that described it in isolated, and wrote another filter script to subtract it as well.

8891 AAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRAASSSSSSSSSSSSSSSSAAAAAAAAAAAAAAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAASSSSSSSSSSSSSSSSA
8892 AAAAAAAAAAAASSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSAATTTTTTTTTTTTTTTTAAAAAAAAAAAAAAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAATTTTTTTTTTTTTTTTA
8893 AAAAAAAAAAAATTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTAAUUUUUUUUUUUUUUUUAAAAAAAAAAAAAAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAAUUUUUUUUUUUUUUUUA
8894 AAAAAAAAAAAAUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUAAV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AALLLLLLLLLLLLLLLLKKKKKKKKKKKKKKKKAFFFFFFFFFFFFFFFFAA
8939 AAAAAAAAAAAAGHHHHHHHHHHHHHHHHGGGGGGGGGGGGGGGAGGGGGGGGGGGGGGGGAAAAAAAAAAAAAAAAMMMMMMMMMMMMMMMMLLLLLLLLLLLLLLLLAGGGGGGGGGGGGGGGGAA

Once again, the remaining patterns in the encrypted grids were blockier and easier to see. Hot on these successes, I continued to identify patterns, describe them, and subtract them out. Before long, there was nothing left but some odd patches:

8891 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASSSSSSSSSSSSSSSSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASSSSSSSSSSSSSSSSA
8892 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATTTTTTTTTTTTTTTTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATTTTTTTTTTTTTTTTA
8893 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUUUUUUUUUUUUUUUUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUUUUUUUUUUUUUUUUA
8894 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVVVVVVVVVVVVVVVVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVVVVVVVVVVVVVVVVA
8895 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWWWWWWWWWWWWWWWWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWWWWWWWWWWWWWWWWA
8896 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXXXXXXXXXXXXXXXXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8934 AAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAA
8935 AAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAACCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAACCCCCCCCCCCCCCCCAA
8936 AAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDAA
8937 AAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAEEEEEEEEEEEEEEEEAA
8938 AAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAFFFFFFFFFFFFFFFFAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAFFFFFFFFFFFFFFFFAA
8939 AAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGGAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGGAA

And when I subtracted those out, all that was left was a sea of As that represented the original, unencrypted grids:

8891 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8892 AAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8937 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8938 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8939 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

I now had a sequence of steps that described the encryption process as the union of five or six simpler processes. I thought of them as layers, each one overlaid on top of the others. Like the reordering formulas, it seemed a little too complicated to be the actual process, but nonetheless it worked.

Except, that is, when it didn't:

7581 AAAAAAAZZAAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAAAAAAAAAAAAAAAAAAAAAAAAAACABZAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYBZBZBZBZBZBZBZBZBZBZ
7582 AAAAAAAZZAAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAAAAAAAAAAAAAAAAAAAAAAAAAACABZAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYBZBZBZBZBZBZBZBZBZBZ
7583 AAAAAAAZZAAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZAAAAAAAAAAAAAAAAAAAAAAAAAAACABZAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYBZBZBZBZBZBZBZBZBZBZ
7584 AAAAAAAZZAAZZZZZZZZZZZZZZZZZZZZZZ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AKAKAKAKAKAKAFVFVFVFVFVFVFVFVFVFVF

Odd-sized grids proved to be different in ways that I couldn't just capture as a minor variation (as I had with the formulas for the underlying quartet layer), and I wound up identifying three more layers that only appeared on odd grids. Worse yet, even after adding these, I found that smaller-sized grids turned up more exceptions, just as it had with my description of the reordering algorithm.

The Reordering Process: The Brick Wall

Let me switch gears again to the reordering process. All of my original attempts to describe the reordering were done with scattered data points. Now that I had a full set of data for several different grid sizes, I had a different view of the stride patterns.

7581 0F 0000018040300000100000010000010004030000001000001000001080040300000100000100000010004030000010000021
7582 0D 0000018040300000010000010000010004021000001000001000001080040300000100000100000010004030000010000021
7583 0B 0000018040300000010000010000010004021000001000001000000180040300000100000210000010004030000010000021
7584 09 0000018040210000010000010000010004021000001000001000000180040300000100000210000010004030000001000021
7585 07 0000018040210000010000010000001004021000001000002100000180040300000100000210000010004030000001000021
7586 05 0000018040210000010000010000001004021000001000002100000180040300000010000210000010004021000001000021
7587 03 0000007040210000010000021000001004021000001000002100000180040300000010000210000010004021000001000021
7588 01 0000007040210000010000021000001004021000000100002100000180040210000010000210000010004021000001000021
7589 62 1000007040210000010000021000001004021000000100002100000180040210000010000210000001004021000001000020
7591 0B 0000018040300000010000010000010004003000001000001000000180040300000100000210000010004030000010000001
7592 09 0000018040210000010000010000010004003000001000001000000180040300000100000210000010004030000001000001
7593 07 0000018040210000010000010000001004003000001000002100000180040300000100000210000010004030000001000001
7594 05 0000018040210000010000010000001004003000001000002100000180040300000010000210000010004021000001000001
7595 03 0000007040210000010000021000001004003000001000002100000180040300000010000210000010004021000001000001
7596 01 0000007040210000010000021000001004003000000100002100000180040210000010000210000010004021000001000001
7597 62 1000007040210000010000021000001004003000000100002100000180040210000010000210000001004021000001000002
7598 60 1000007040210000001000021000001004002100000100002100000180040210000010000210000001004021000001000002
7599 5E 1000007040210000001000021000001004002100000100002100000090040210000010000201000001004021000001000002
7611 23 0000108007000001000002100000100000100000100000010000010080070000001000001000001000004300000100000100
7612 21 0000108007000001000002100000100000100000010000010000010080061000001000001000001000004300000100000100
7613 1F 0000108007000001000002100000100000100000010000010000010080061000001000001000000100004300000100000210
7614 1D 0000108007000000100002100000100000210000010000010000010080061000001000001000000100004300000100000210
7615 1B 0000108007000000100002100000100000210000010000010000001080061000001000002100000100004300000100000210
7616 19 0000108006100000100002100000100000210000010000010000001080061000001000002100000100004300000010000210
7617 17 0000108006100000100002100000010000210000010000021000001080061000001000002100000100004300000010000210
7618 15 0000108006100000100002100000010000210000010000021000001080061000000100002100000100004210000010000210
7619 13 0000018006100000100002010000010000210000010000021000001080061000000100002100000100004210000010000210
7621 1F 0000108007000001000000100000100000100000010000010000010080043000001000001000000100004300000100000210
7622 1D 0000108007000000100000100000100000210000010000010000010080043000001000001000000100004300000100000210
7623 1B 0000108007000000100000100000100000210000010000010000001080043000001000002100000100004300000100000210
7624 19 0000108006100000100000100000100000210000010000010000001080043000001000002100000100004300000010000210
7625 17 0000108006100000100000100000010000210000010000021000001080043000001000002100000100004300000010000210
7626 15 0000108006100000100000100000010000210000010000021000001080043000000100002100000100004210000010000210
7627 13 0000018006100000100000210000010000210000010000021000001080043000000100002100000100004210000010000210
7628 11 0000018006100000100000210000010000210000001000021000001080042100000100002100000100004210000010000210
7629 0F 0000018006100000100000210000010000210000001000021000001080042100000100002100000010004210000010000201

Comparing with some of the earlier images of the where the strides appeared, it was now easier to find commonalities in the places where my current algorithm got the placement of the firings wrong. Notice, for example, the four lines in the above output where a +1 firing occurs at the very first position (in bright blue). An unusual thing, and not something that my equations currently allowed for at all. What's really happening, though, is that the rightmost +1 firing is wrapping around to the front again. If you look closely, you can see that +1 firing disappearing off the right edge and reappearing on the left for those values. Notice that those grids are ones with high values for c and d. And, notice that those grids also have very different values for the initial position. (The initial position is indicated by the two-digit hex value immediately after the key.) Now what's interesting here is that my current equation for calculating the initial position correctly predicted the wraparound here, but its values were actually off by one. If you look at the initial position values immediately before the wraparound, you can see that they diminish by two as the value of d increases. But then, at the point of wraparound the value suddenly changes from odd to even, as the value diminishes by three instead of two. Why? I couldn't say. Once again, this only happened for even grids; on odd grids, a simple modulus operations captured the wraparound. But I did my best to capture this behavior in another equation and added it as a further refinement to my reordering algorithm. Some random spot checking suggested that I now could correctly predict the reordering of all grids that were large than 55 or so. Below that, errors started to appear, getting more numerous as the grid size got smaller and smaller. (At the minimum grid size of 12, almost every grid had at least one error.)

So here is where things stood for me. On the one hand, I had a complete unscrambling algorithm, covering both encryption and reordering, that worked correctly for something like 90% of all possible grids, including almost all real-word crosswords. (Even a small crossword puzzle typically has over 100 white squares.) On the other hand, the algorithm was ridiculously complicated, spread out over several scripts, and it was obviously not correct, since its errors got worse and worse as the grid size shrank. There was no way that the algorithm I had, for all of its successes, looked anything the real unscrambling algorithm.

I felt strongly that I had come to a turning point. The fact that both my reordering and my encryption algorithms failed as the grid decreased in size felt too compelling to be a coincidence. I felt that I was at the point where I had to turn my back on epicycles and embrace ellipses. But I still had no idea what that meant; I had no idea what my ellipses were. But my gut told me that collecting more data wasn't going to help. I was already at the point where I had to start making leaps.

Part of the problem, of course, was that I had collected all these scripts that provided visualizations based on my current approach. All the ways I had of looking at my data were colored by my current model (quite literally, in most cases). So I started forcing myself to get away from my computer and think about alternate ways to model the behavior.

So I spent some time floundering like this, toying with alternative models. Despite the effort I put into it, I only came up with one idea that appealed to me at all.

This idea was to view the grid not as a single row, but as a sequence of rows, each 16 positions long. With the rows stacked up from top to bottom, this would create a set of 16 columns. This was attractive for the reordering process, because it meant that most of the letters would be filled in by simply going down the columns. My so-called firings would then appear as points in which the sequence jumped from one column to a different column. Hopefully, I thought that looking at it this way might cause the firings (or rather the column changes) to assemble into a visible pattern.

The Reordering Process: Sixteen Columns

So, after a period of time in which I failed to come up with a better idea for a new model, I sat down and started writing some new scripts to display my collected data in this way. Right off I found it frustrating because, since I was using a two-dimensional shape to display the grids, I couldn't fit nearly as many grids into a single window. But after looking at them for a while, I began to see some promising avenues.

5936
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
        69 125 117 109 101  93  85  77   5  61  53  45  37  29  21  13
        70 126 118 110 102  94  86  78   6  62  54  46  38  30  22  14
        71 127 119 111 103  95  87  79   7  63  55  47  39  31  23  15
        72   0 120 112 104  96  88  80   8  64  56  48  40  32  24  16
        73   1 121 113 105  97  89  81  41  65  57  49   9  33  25  17
       106   2 122 114  90  98  74  82  58  66  42  50  26  34  10  18
5975
        19  11   4 124 116 108 100  92  84  76  68  60  52  44  36  28
        20  12  69 125 117 109 101  93  85  77   5  61  53  45  37  29
        21  13  70 126 118 110 102  94  86  78   6  62  54  46  38  30
        22  14  71 127 119 111 103  95  87  79   7  63  55  47  39  31
        23  15  72   0 120 112 104  96  88  80   8  64  56  48  40  32
        24  16  73   1 121 113 105  97  89  81  41  65  57  49   9  33
        25  17 106   2 122 114  74  98  90  82  42  66  58  50  10  34
        26  18 107   3 123 115  91  99  75  83  59  67  43  51  27  35
6264
         1 121 113 105  97  89  81  73  65  57  49  41  33  25  17   9
         2 122 114 106  98  90  82  74  66  58  50  42  34  26  18  10
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
        70 126 118 110 102  94  86  78   6  62  54  46  38  30  22  14
       103 127 119 111  71  95  87  79  39  63  55  47   7  31  23  15
       104   0 120 112  72  96  88  80  56  64  40  48  24  32   8  16
6645
        50  42  34  26  18  10   3 123 115 107  99  91  83  75  67  59
        51  43  35  27  19  11   4 124 116 108 100  92  84  76  68  60
        52  44  36  28  20  12   5 125 117 109 101  93  85  77  69  61
        53  45  37  29  21  13  70 126 118 110 102  94  86  78   6  62
        54  46  38  30  22  14  71 127 119 111 103  95  87  79   7  63
        55  47  39  31  23  15  72   0 120 112 104  96  88  80   8  64
        56  48  40  32  24  16 105   1 121 113  73  97  89  81  41  65
        57  49   9  33  25  17 122   2 106 114  90  98  74  82  58  66

Since the strides are now displayed spatially instead of numerically, the contents of the grid are just indicated by the numbers 0 through 127 (since this shows grids of size 128). The brightly-colored numbers show the column switches, where the sequence switches from one column to another. Beyond that the columns are color-coded for even and odd columns, just as a minor visual aid.

Right away I started noticing patterns in this new visualization. The +1 and –1 jumps (i.e. the firings in the previous model) only occur at the end of the columns, just before jumping back to the top of another column. Likewise, the +2 and –2 jumps occured close to the end of columns, though almost never at the very end. I also noticed that the places where my old model was still mis-predicting a +1 or –1 firing were, in the new model, where the column jump caused a wraparound from the end of the buffer to the front. Of course, these patterns were still pretty vague, but the new model seemed to have promise.

At some point I was looking at the initial position. As mentioned earlier, the initial position tended to decrease by two as the last digit in the key increased by one, with exceptions such as when it wrapped around from the front to the back.

8936
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
         7 127 119 111 103  95  87  79  71  63  55  47  39  31  23  15
        72   0 120 112 104  96  88  80   8  64  56  48  40  32  24  16
        73   1 121 113 105  97  89  81   9  65  57  49  41  33  25  17
        74   2 122 114 106  98  90  82  10  66  58  50  42  34  26  18
        75   3 123 115 107  99  91  83  11  67  59  51  43  35  27  19
        76   4 124 116 108 100  92  84  44  68  60  52  12  36  28  20
       109   5 125 117  93 101  77  85  61  69  45  53  29  37  13  21
8937
       118 110 102  94  86  78  70  62  54  46  38  30  22  14   7 127
       119 111 103  95  87  79  71  63  55  47  39  31  23  15  72   0
       120 112 104  96  88  80   8  64  56  48  40  32  24  16  73   1
       121 113 105  97  89  81   9  65  57  49  41  33  25  17  74   2
       122 114 106  98  90  82  10  66  58  50  42  34  26  18  75   3
       123 115 107  99  91  83  11  67  59  51  43  35  27  19  76   4
       124 116 108 100  92  84  44  68  60  52  12  36  28  20 109   5
       125 117  93 101  77  85  61  69  45  53  29  37  13  21 126   6
8938
       102  94  86  78  70  62  54  46  38  30  22  14   7 127 119 111
       103  95  87  79  71  63  55  47  39  31  23  15  72   0 120 112
       104  96  88  80   8  64  56  48  40  32  24  16  73   1 121 113
       105  97  89  81   9  65  57  49  41  33  25  17  74   2 122 114
       106  98  90  82  10  66  58  50  42  34  26  18  75   3 123 115
       107  99  91  83  11  67  59  51  43  35  27  19  76   4 124 116
       108 100  92  84  44  68  60  52  12  36  28  20 109   5 125 117
        93 101  77  85  61  69  45  53  29  37  13  21 126   6 110 118
8939
        86  78  70  62  54  46  38  30  22  14   7 127 119 111 103  95
        87  79  71  63  55  47  39  31  23  15  72   0 120 112 104  96
        88  80   8  64  56  48  40  32  24  16  73   1 121 113 105  97
        89  81   9  65  57  49  41  33  25  17  74   2 122 114 106  98
        90  82  10  66  58  50  42  34  26  18  75   3 123 115 107  99
        91  83  11  67  59  51  43  35  27  19  76   4 124 116 108 100
        92  84  44  68  60  52  12  36  28  20 109   5 125 117  93 101
        77  85  61  69  45  53  29  37  13  21 126   6 110 118  94 102

As I mentioned, it was harder to see patterns in consecutive grids in the new display, but eventually I realized: It wasn't just the initial position that was moving back two places as the key increased. Actually, the entire grid was moving back two places, as a solid block. The only exception were the two positions that fell off the front and wrapped around to the back. They had swapped positions with each other. I looked more closely and saw that, yes, that was a consistent pattern. As positions wrapped around from the front to the back in pairs, their order would be reversed. Spot-checking throughout my collected data sets showed that this behavior was consistent regardless of the grid size. Consistent among even grids, that is: odd grids didn't reverse the pair order when wrapping around, but otherwise showed the same shifting pattern.

This may sound too obvious to be worth pointing out explicitly, but I'm going to anyway: This pattern of left-shifting constituted the full contribution of the key's fourth digit to the reordering process. It's not used any further. (Because it if was, it would be visible.) So we can factor it out, just like we factored out the various encryption layers, and hopefully what's left will be simplified. In this case, there's an obvious way to factor the fourth digit out, and that is to extrapolate backwards to a zero digit. The key never contains zero digits, but as we right-shift to go from a digit of three to two to one, one more shift will give us the grid for a zero digit.

So I wrote a script to generate a full set of 729 grids that had a zero for the fourth digit, for a handful of grid sizes, and examined them.

8910
        36  28  20  12   5 125 117 109 101  93  85  77  69  61  53  45
        37  29  21  13   6 126 118 110 102  94  86  78  70  62  54  46
        38  30  22  14   7 127 119 111 103  95  87  79  71  63  55  47
        39  31  23  15  72   0 120 112 104  96  88  80   8  64  56  48
        40  32  24  16  73   1 121 113 105  97  89  81   9  65  57  49
        41  33  25  17  74   2 122 114 106  98  90  82  10  66  58  50
        42  34  26  18  75   3 123 115 107  99  91  83  11  67  59  51
        43  35  27  19  76   4 124 116 108 100  92  84  44  68  60  52
8920
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
         7 127 119 111 103  95  87  79  71  63  55  47  39  31  23  15
        72   0 120 112 104  96  88  80   8  64  56  48  40  32  24  16
        73   1 121 113 105  97  89  81   9  65  57  49  41  33  25  17
        74   2 122 114 106  98  90  82  10  66  58  50  42  34  26  18
        75   3 123 115 107  99  91  83  11  67  59  51  43  35  27  19
        76   4 124 116 108 100  92  84  44  68  60  52  12  36  28  20
8930
       101  93  85  77  69  61  53  45  37  29  21  13   6 126 118 110
       102  94  86  78  70  62  54  46  38  30  22  14   7 127 119 111
       103  95  87  79  71  63  55  47  39  31  23  15  72   0 120 112
       104  96  88  80   8  64  56  48  40  32  24  16  73   1 121 113
       105  97  89  81   9  65  57  49  41  33  25  17  74   2 122 114
       106  98  90  82  10  66  58  50  42  34  26  18  75   3 123 115
       107  99  91  83  11  67  59  51  43  35  27  19  76   4 124 116
       108 100  92  84  44  68  60  52  12  36  28  20 109   5 125 117
8940
        69  61  53  45  37  29  21  13   6 126 118 110 102  94  86  78
        70  62  54  46  38  30  22  14   7 127 119 111 103  95  87  79
        71  63  55  47  39  31  23  15  72   0 120 112 104  96  88  80
         8  64  56  48  40  32  24  16  73   1 121 113 105  97  89  81
         9  65  57  49  41  33  25  17  74   2 122 114 106  98  90  82
        10  66  58  50  42  34  26  18  75   3 123 115 107  99  91  83
        11  67  59  51  43  35  27  19  76   4 124 116 108 100  92  84
        44  68  60  52  12  36  28  20 109   5 125 117  77 101  93  85

It's now easy to see the influence of the third digit on the reordering process. It proves to be similar in nature, but now four positions are getting shifted left instead of two. And we can see that the four positions that wrap around aren't getting completely reversed, but rather than the last position is getting shifted to the first. (Sort of a right-shift inside of a left-shift: mobilis in mobili.) Again, the odd-sized grids show the same shifting-by-four but without the back-to-front shuffle.

The next step, of course, is to extrapolate to grids with a zero digit in the third position, and generate a set of 81 grids for keys ending in 00:

8600
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
         7 127 119 111 103  95  87  79  71  63  55  47  39  31  23  15
        72   0 120 112 104  96  88  80   8  64  56  48  40  32  24  16
        73   1 121 113 105  97  89  81   9  65  57  49  41  33  25  17
        74   2 122 114 106  98  90  82  10  66  58  50  42  34  26  18
8700
        67  59  51  43  35  27  19  11   4 124 116 108 100  92  84  76
        68  60  52  44  36  28  20  12   5 125 117 109 101  93  85  77
        69  61  53  45  37  29  21  13   6 126 118 110 102  94  86  78
        70  62  54  46  38  30  22  14   7 127 119 111 103  95  87  79
        71  63  55  47  39  31  23  15  72   0 120 112 104  96  88  80
         8  64  56  48  40  32  24  16  73   1 121 113 105  97  89  81
         9  65  57  49  41  33  25  17  74   2 122 114 106  98  90  82
        10  66  58  50  42  34  26  18  75   3 123 115 107  99  91  83
8800
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
         7 127 119 111 103  95  87  79  71  63  55  47  39  31  23  15
        72   0 120 112 104  96  88  80   8  64  56  48  40  32  24  16
        73   1 121 113 105  97  89  81   9  65  57  49  41  33  25  17
        74   2 122 114 106  98  90  82  10  66  58  50  42  34  26  18
        75   3 123 115 107  99  91  83  11  67  59  51  43  35  27  19
8900
        68  60  52  44  36  28  20  12   5 125 117 109 101  93  85  77
        69  61  53  45  37  29  21  13   6 126 118 110 102  94  86  78
        70  62  54  46  38  30  22  14   7 127 119 111 103  95  87  79
        71  63  55  47  39  31  23  15  72   0 120 112 104  96  88  80
         8  64  56  48  40  32  24  16  73   1 121 113 105  97  89  81
         9  65  57  49  41  33  25  17  74   2 122 114 106  98  90  82
        10  66  58  50  42  34  26  18  75   3 123 115 107  99  91  83
        11  67  59  51  43  35  27  19  76   4 124 116 108 100  92  84

As I'm sure you've already guessed, they show a left-shift of eight positions as the second digit increases, and with the same back-to-front shuffle on wraparound for the even grids. There are only 9 grids for keys that end in 000, giving this:

6000
       126 118 110 102  94  86  78  70  62  54  46  38  30  22  14   6
       127 119 111 103  95  87  79  71  63  55  47  39  31  23  15   7
         0 120 112 104  96  88  80  72  64  56  48  40  32  24  16   8
         1 121 113 105  97  89  81  73  65  57  49  41  33  25  17   9
         2 122 114 106  98  90  82  74  66  58  50  42  34  26  18  10
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
7000
       127 119 111 103  95  87  79  71  63  55  47  39  31  23  15   7
         0 120 112 104  96  88  80  72  64  56  48  40  32  24  16   8
         1 121 113 105  97  89  81  73  65  57  49  41  33  25  17   9
         2 122 114 106  98  90  82  74  66  58  50  42  34  26  18  10
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
8000
         0 120 112 104  96  88  80  72  64  56  48  40  32  24  16   8
         1 121 113 105  97  89  81  73  65  57  49  41  33  25  17   9
         2 122 114 106  98  90  82  74  66  58  50  42  34  26  18  10
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
         7 127 119 111 103  95  87  79  71  63  55  47  39  31  23  15
9000
         1 121 113 105  97  89  81  73  65  57  49  41  33  25  17   9
         2 122 114 106  98  90  82  74  66  58  50  42  34  26  18  10
         3 123 115 107  99  91  83  75  67  59  51  43  35  27  19  11
         4 124 116 108 100  92  84  76  68  60  52  44  36  28  20  12
         5 125 117 109 101  93  85  77  69  61  53  45  37  29  21  13
         6 126 118 110 102  94  86  78  70  62  54  46  38  30  22  14
         7 127 119 111 103  95  87  79  71  63  55  47  39  31  23  15
         8   0 120 112 104  96  88  80  72  64  56  48  40  32  24  16

The pattern continues: a left-shift of sixteen positions as the first digit increases. So we extrapolate backwards from these:

0000
       120 112 104  96  88  80  72  64  56  48  40  32  24  16   8   0
       121 113 105  97  89  81  73  65  57  49  41  33  25  17   9   1
       122 114 106  98  90  82  74  66  58  50  42  34  26  18  10   2
       123 115 107  99  91  83  75  67  59  51  43  35  27  19  11   3
       124 116 108 100  92  84  76  68  60  52  44  36  28  20  12   4
       125 117 109 101  93  85  77  69  61  53  45  37  29  21  13   5
       126 118 110 102  94  86  78  70  62  54  46  38  30  22  14   6
       127 119 111 103  95  87  79  71  63  55  47  39  31  23  15   7

And here, at last, is the original Ur-sequence: The ordering of positions before the key-based scrambling is done. With this, I had finally cracked the actual scrambling algorithm once and for all. My pseudocode looked like this:

tmp[0..N] = solution[0..N]
j = 1
for 0 ≤ i < N
j += 16
j –= N | 1 while jN
solution[j] = tmp[i]
for 0 ≤ k < 4
n = 24k
n –= N | 1 if n < N
for 0 ≤ i < key[k]
rotate solution[0..n], +1 if N % 2 == 0
rotate solution[0..N], n

The unusual adjustment of line 9 is to handle the special case of a grid that has less than 16 positions. You may recall that the scrambling algorithm permits grid sizes as small as 12 positions. That special case also the reason why line 5 needs to use while instead of if. (If you're unfamiliar with the C bitwise operators, the expression N | 1 simply gives N when N is odd, and N + 1 when N is even.)

With this major milestone checked off of my to-do list, I then turned my full attention back to the encryption process.

The Encryption Process: Layers Between Layers

My current set of layers worked for grid sizes down to about 50 or so. By adding more layers, layers that had no effect on larger grids, I managed to improve my encryption model so that it worked correctly for all grids of size 20 and above. For all practical purposes, I had a working encryption algorithm — who cares about crossword puzzles with less than 20 squares? — but it was ridiculously complicated and obviously not representative of the real algorithm.

Instinctively I guessed that I had incorrectly identified several of the layers, and that certain layers when combined, would cancel out a lot of unnecessary complexity, and leave me with fewer layers that were more well-behaved. Unfortunately, this theory failed to be borne out in practice: The layers kept failing to line up with each other consistently.

But: I was still better off than I was. The nice thing about having a overly-complicated working model, is that I had a working model that expressed the change to each letter in terms of the digits from the key. Instead of just saying e.g. "This position had thirteen added to it," I could say, "This position had increased by c plus three times d." This would represent the sum total of all of the encryption layers onto a single position. I therefore started working on a tool that would display the encryption for each position by how many times each key digit was added (or subtracted) from the original letter. My hope, of course, was that displaying the four coefficients for each position might make new patterns visible, and point the way to reorganizing the layers.

I never came up with a good way to represent this information visually, but as it turned out it didn't matter. The first rough version of my script quickly showed me two new facts. First, I found that the coefficients were never negative. This was surprising, since nearly all of the layers subtracted some values. But all of the subtractions were balanced out by other additions. That argued strongly that all of the subtractions were just manifestations of incorrect layer separation — which worried me, since that included pretty much all of them. The second fact, however, rendered that nearly irrelevant. I realized that the total number of factors (i.e. the sum of all four coefficients) always added up to four. For every position in every grid, without fail.

This is a pretty big example of an invariant that one would expect to be more prominently visible in the actual algorithm.

My initial gut reaction was to throw out the all of my layer work and start over. Once I calmed down, however, and started looking at it with a clearer head, I began to see interesting patterns.

First I made a handful of attempts to construct a model that enforced the four-coefficients requirement, but I quickly discarded them all as being unlikely. Eventually I connected the requirement with the fact that there were four stages to the reordering process. For most of this time, I had tentatively assumed that the encryption and reordering processes were separate stages. But now that I had a clear understanding of the reordering process — i.e. I knew that it occurred in four phases, and I had a sense what the grid looked like in between each phase — it seemed entirely possible that some or all of the irregularities in the positioning of the encryption layers could be because they were done in between the reordering steps, on a partly rearranged grid.

The Scrambling Process

Investigating this called for some new tools. Up until then I had been doing colorized output separately in each script, hardcoding the colors for whatever feature I was trying to look at. Now that I wanted to display a lot more data at once, I decided to try a different approach. My new scripts would "mark up" each character in the output with arbitrary attributes, by appending extra data to each character of output. I then had a separate script that would read in all of the output, and dynamically select colors at runtime for each unique combination of attributes. This put all the colorizing in one place, which made it easier to write scripts that could read the output of another script (since it was easier to subject my markup to a read-modify-write process than ANSI escape sequences).

I had already written a nice little script that could do selective decryption. As I had separated out the various layers, I had given each one a vaguely descriptive name (stripes, bands, spike, and so on), and I had written a script that removed layers selectively, allowing me to specify on the command line which ones to undo and which ones to leave in the output. Now that I understood how the reordering was done, I wrote another script that allowed me to selectively undo the various reordering phases. With this arsenal, I could now do some serious exploration of how the reordering and the encryption steps interacted with each other.

8891             8892             8893             8894             8895             8896             8897             8898             8899
HIIBHIIBIBJUZSAHIICHIICICJWAUBHIIDHIIDIDJYBWCHIIEHIIEIEJACYDHIIFHIIFIFJCDAEHIIGHIIGIGJEECFHIIHHIIHIHJGFEGHIIIHIIIIIJIGGHHIIJHIIJIJJKHIIJ
ZSALZSALZSALZSAAUBOAUBOAUBOAUBBWCRBWCRBWCRBWCCYDUCYDUCYDUCYDDAEXDAEXDAEXDAEECFAECFAECFAECFFEGDFEGDFEGDFEGGGHGGGHGGGHGGGHHIIJHIIJHIIJHIIJ
ZSALZSALZSALIBBAUBOAUBOAUBOICCBWCRBWCRBWCRIDDCYDUCYDUCYDUIEEDAEXDAEXDAEXIFFECFAECFAECFAIGGFEGDFEGDFEGDIHHGGHGGGHGGGHGIIIHIIJHIIJHIIJIJJK
ATBMATBMATBMATJBVCPBVCPBVCPBVJCXDSCXDSCXDSCXJDZEVDZEVDZEVDZJEBFYEBFYEBFYEBJFDGBFDGBFDGBFDJGFHEGFHEGFHEGFJHHIHHHIHHHIHHHJIJJKIJJKIJJKIJJK
IBJUIBJUHIIBGHHICJWICJWHIICGHHIDJYIDJYHIIDGHHIEJAIEJAHIIEGHHIFJCIFJCHIIFGHHIGJEIGJEHIIGGHHIHJGIHJGHIIHGHHIIJIIIJIHIIIGHHIJJKIJJKHIIJGHHI
GHHAGHHAGHHAGHHGHHBGHHBGHHBGHHGHHCGHHCGHHCGHHGHHDGHHDGHHDGHHGHHEGHHEGHHEGHHGHHFGHHFGHHFGHHGHHGGHHGGHHGGHHGHHHGHHHGHHHGHHGHHIGHHIGHHIGHHI
GHHAGHHAGHHAHIIGHHBGHHBGHHBHIIGHHCGHHCGHHCHIIGHHDGHHDGHHDHIIGHHEGHHEGHHEHIIGHHFGHHFGHHFHIIGHHGGHHGGHHGHIIGHHHGHHHGHHHHIIGHHIGHHIGHHIHIIJ
ZAATZAATZAATZAAB ABBVABBVABBVABBC BCCXBCCXBCCXBCCD CDDZCDDZCDDZCDDE DEEBDEEBDEEBDEEF EFFDEFFDEFFDEFFG FGGFFGGFFGGFFGGH GHHHGHHHGHHHGHHI HIIJHIIJHIIJHIIJ
8911             8912             8913             8914             8915             8916             8917             8918             8919
SMLESMLEATTLJCCSMLFSMLFAUTNJDCSMLGSMLGAVTPJECSMLHSMLHAWTRJFCSMLISMLIAXTTJGCSMLJSMLJAYTVJHCSMLKSMLKAZTXJICSMLLSMLLAATZJJCSMLMSMLMABTBJKCK
JCCUJCCUJCCUIBBJDCWJDCWJDCWICBJECYJECYJECYIDBJFCAJFCAJFCAIEBJGCCJGCCJGCCIFBJHCEJHCEJHCEIGBJICGJICGJICGIHBJJCIJJCIJJCIIIBJKCKJKCKJKCKIJBJ
IBBTIBBTIBBTATTICBVICBVICBVAVUIDBXIDBXIDBXAXVIEBZIEBZIEBZAZWIFBBIFBBIFBBABXIGBDIGBDIGBDADYIHBFIHBFIHBFAFZIIBHIIBHIIBHAHAIJBJIJBJIJBJAJBJ
ATTLATTLATTLATTBVUOBVUOBVUOBUTCXVRCXVRCXVRCVTDZWUDZWUDZWUDWTEBXXEBXXEBXXEXTFDYAFDYAFDYAFYTGFZDGFZDGFZDGZTHHAGHHAGHHAGHATIJBJIJBJIJBJIBTB
ATTLATTLSMLESUTAUTNAUTNSMLFSVUAVTPAVTPSMLGSWVAWTRAWTRSMLHSXWAXTTAXTTSMLISYXAYTVAYTVSMLJSZYAZTXAZTXSMLKSAZAATZAATZSMLLSBAABTBABTBSMLMSCBC
AUTMAUTMAUTMATSBVUOBVUOBVUOBUTCWVQCWVQCWVQCVUDXWSDXWSDXWSDWVEYXUEYXUEYXUEXWFZYWFZYWFZYWFYXGAZYGAZYGAZYGZYHBAAHBAAHBAAHAZICBCICBCICBCIBAB
ZTSLZTSLZTSLZMLAUTNAUTNAUTNANMBVUPBVUPBVUPBONCWVRCWVRCWVRCPODXWTDXWTDXWTDQPEYXVEYXVEYXVERQFZYXFZYXFZYXFSRGAZZGAZZGAZZGTSHBABHBABHBABHUTU
SMLESMLESMLESMLE TNMGTNMGTNMGTMLF UONIUONIUONIUMLG VPOKVPOKVPOKVMLH WQPMWQPMWQPMWMLI XRQOXRQOXRQOXMLJ YSRQYSRQYSRQYMLK ZTSSZTSSZTSSZMLL AUTUAUTUAUTUAMLM
8921             8922             8923             8924             8925             8926             8927             8928             8929
AVUNAVUNHABSCUVAVUOAVUOHBBUCWWAVUPAVUPHCBWCYXAVUQAVUQHDBYCAYAVURAVURHEBACCZAVUSAVUSHFBCCEAAVUTAVUTHGBECGBAVUUAVUUHHBGCICAVUVAVUVHIBICKDK
BUVMBUVMBUVMBVWCWWPCWWPCWWPCWWDYXSDYXSDYXSDXWEAYVEAYVEAYVEYWFCZYFCZYFCZYFZWGEABGEABGEABGAWHGBEHGBEHGBEHBWIICHIICHIICHICWJKDKJKDKJKDKJDWD
CVWNCVWNCVWNHBCCWWPCWWPCWWPHCCCXWRCXWRCXWRHDCCYWTCYWTCYWTHECCZWVCZWVCZWVHFCCAWXCAWXCAWXHGCCBWZCBWZCBWZHHCCCWBCCWBCCWBHICCDWDCDWDCDWDHJCJ
IBCTIBCTIBCTIABICCVICCVICCVIBBIDCXIDCXIDCXICBIECZIECZIECZIDBIFCBIFCBIFCBIEBIGCDIGCDIGCDIFBIHCFIHCFIHCFIGBIICHIICHIICHIHBIJCJIJCJIJCJIIBI
HABSHABSAVUNANMHBBUHBBUAVUOAPOHCBWHCBWAVUPARQHDBYHDBYAVUQATSHEBAHEBAAVURAVUHFBCHFBCAVUSAXWHGBEHGBEAVUTAZYHHBGHHBGAVUUABAHIBIHIBIAVUVADCD
SNMFSNMFSNMFSONG UPOIUPOIUPOIUPOI WRQLWRQLWRQLWQPK YTSOYTSOYTSOYRQM AVURAVURAVURASRO CXWUCXWUCXWUCTSQ EZYXEZYXEZYXEUTS GBAAGBAAGBAAGVUU IDCDIDCDIDCDIWVW
TONGTONGTONGTWVO UPOIUPOIUPOIUWVP VQPKVQPKVQPKVWVQ WRQMWRQMWRQMWWVR XSROXSROXSROXWVS YTSQYTSQYTSQYWVT ZUTSZUTSZUTSZWVU AVUUAVUUAVUUAWVV BWVWBWVWBWVWBWVW
BWVOBWVOBWVOBVUBWVPBWVPBWVPBVUBWVQBWVQBWVQBVUBWVRBWVRBWVRBVUBWVSBWVSBWVSBVUBWVTBWVTBWVTBVUBWVUBWVUBWVUBVUBWVVBWVVBWVVBVUBWVWBWVWBWVWBVUV
8931             8932             8933             8934             8935             8936             8937             8938             8939
WSRKWSRKCVXNICEWSRLWSRLCWXPIDEWSRMWSRMCXXRIEEWSRNWSRNCYXTIFEWSROWSROCZXVIGEWSRPWSRPCAXXIHEWSRQWSRQCBXZIIEWSRRWSRRCCXBIJEWSRSWSRSCDXDIKEK
JCEUJCEUJCEUJBDJDEWJDEWJDEWJCDJEEYJEEYJEEYJDDJFEAJFEAJFEAJEDJGECJGECJGECJFDJHEEJHEEJHEEJGDJIEGJIEGJIEGJHDJJEIJJEIJJEIJIDJKEKJKEKJKEKJJDJ
IBDTIBDTIBDTCTVICDVICDVICDVCVWIDDXIDDXIDDXCXXIEDZIEDZIEDZCZYIFDBIFDBIFDBCBZIGDDIGDDIGDDCDAIHDFIHDFIHDFCFBIIDHIIDHIIDHCHCIJDJIJDJIJDJCJDJ
ATVLATVLATVLAVXBVWOBVWOBVWOBWXCXXRCXXRCXXRCXXDZYUDZYUDZYUDYXEBZXEBZXEBZXEZXFDAAFDAAFDAAFAXGFBDGFBDGFBDGBXHHCGHHCGHHCGHCXIJDJIJDJIJDJIDXD
CVXNCVXNWSRKWWVCWXPCWXPWSRLWXWCXXRCXXRWSRMWYXCYXTCYXTWSRNWZYCZXVCZXVWSROWAZCAXXCAXXWSRPWBACBXZCBXZWSRQWCBCCXBCCXBWSRRWDCCDXDCDXDWSRSWEDE
AWVOAWVOAWVOAVUBXWQBXWQBXWQBWVCYXSCYXSCYXSCXWDZYUDZYUDZYUDYXEAZWEAZWEAZWEZYFBAYFBAYFBAYFAZGCBAGCBAGCBAGBAHDCCHDCCHDCCHCBIEDEIEDEIEDEIDCD
ZVUNZVUNZVUNZSPAWVPAWVPAWVPASQBXWRBXWRBXWRBSRCYXTCYXTCYXTCSSDZYVDZYVDZYVDSTEAZXEAZXEAZXESUFBAZFBAZFBAZFSVGCBBGCBBGCBBGSWHDCDHDCDHDCDHSXY
UQPIUQPIUQPIUQRK VRQKVRQKVRQKVRRL WSRMWSRMWSRMWSRM XTSOXTSOXTSOXTRN YUTQYUTQYUTQYURO ZVUSZVUSZVUSZVRP AWVUAWVUAWVUAWRQ BXWWBXWWBXWWBXRR CYXYCYXYCYXYCYRS

In this example the colors indicate how the letter changes (or doesn't change) along with d, the key's fourth digit. Since the colors are now being assigned dynamically, you have to study the output to see what each one indicates. (In this display, for example, green indicates a letter that doesn't change as the digit changes, red indicates a letter that goes up by one as the digit increments, and so forth.) By displaying each grid as a square, that also allowed me to do rough visual comparisons of the third digit, c, as well. (Technically, they're rectangles, since there are twice as many columns as rows.)

8891             8892             8893             8894             8895             8896             8897             8898             8899
AAAAAAAAAAAARRRR AAAAAAAAAAAASSSS AAAAAAAAAAAATTTT AAAAAAAAAAAAUUUU AAAAAAAAAAAAVVVV AAAAAAAAAAAAWWWW AAAA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AAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
8911             8912             8913             8914             8915             8916             8917             8918             8919
AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII AAAAAAAAAAAAIIII
IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA IIIIIIIIIIIIAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAHHH AAAAAAAAAAAAAIII AAAAAAAAAAAAAJJJ AAAAAAAAAAAAAKKK AAAAAAAAAAAAALLL AAAAAAAAAAAAAMMM AAAAAAAAAAAAANNN AAAAAAAAAAAAAOOO AAAAAAAAAAAAAPPP
HHHHHHHHHHHHHHHH IIIIIIIIIIIIIIII JJJJJJJJJJJJJJJJ KKKKKKKKKKKKKKKK LLLLLLLLLLLLLLLL MMMMMMMMMMMMMMMM NNNNNNNNNNNNNNNN OOOOOOOOOOOOOOOO PPPPPPPPPPPPPPPP
HHHHHHHHHHHHHAAA IIIIIIIIIIIIIAAA JJJJJJJJJJJJJAAA KKKKKKKKKKKKKAAA LLLLLLLLLLLLLAAA MMMMMMMMMMMMMAAA NNNNNNNNNNNNNAAA OOOOOOOOOOOOOAAA PPPPPPPPPPPPPAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
8921             8922             8923             8924             8925             8926             8927             8928             8929
AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV AAAAAAAAAAAAVVVV
VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV
VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA VVVVVVVVVVVVAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAATTT AAAAAAAAAAAAAUUU AAAAAAAAAAAAAVVV AAAAAAAAAAAAAWWW AAAAAAAAAAAAAXXX AAAAAAAAAAAAAYYY AAAAAAAAAAAAAZZZ AAAAAAAAAAAAAAAA AAAAAAAAAAAAABBB
TTTTTTTTTTTTTTTT UUUUUUUUUUUUUUUU VVVVVVVVVVVVVVVV WWWWWWWWWWWWWWWW XXXXXXXXXXXXXXXX YYYYYYYYYYYYYYYY ZZZZZZZZZZZZZZZZ AAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBB
TTTTTTTTTTTTTAAA UUUUUUUUUUUUUAAA VVVVVVVVVVVVVAAA WWWWWWWWWWWWWAAA XXXXXXXXXXXXXAAA YYYYYYYYYYYYYAAA ZZZZZZZZZZZZZAAA AAAAAAAAAAAAAAAA BBBBBBBBBBBBBAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
8931             8932             8933             8934             8935             8936             8937             8938             8939
AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG AAAAAAAAAAAAGGGG
GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGG
GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA GGGGGGGGGGGGAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAADDD AAAAAAAAAAAAAEEE AAAAAAAAAAAAAFFF AAAAAAAAAAAAAGGG AAAAAAAAAAAAAHHH AAAAAAAAAAAAAIII AAAAAAAAAAAAAJJJ AAAAAAAAAAAAAKKK AAAAAAAAAAAAALLL
DDDDDDDDDDDDDDDD EEEEEEEEEEEEEEEE FFFFFFFFFFFFFFFF GGGGGGGGGGGGGGGG HHHHHHHHHHHHHHHH IIIIIIIIIIIIIIII JJJJJJJJJJJJJJJJ KKKKKKKKKKKKKKKK LLLLLLLLLLLLLLLL
DDDDDDDDDDDDDAAA EEEEEEEEEEEEEAAA FFFFFFFFFFFFFAAA GGGGGGGGGGGGGAAA HHHHHHHHHHHHHAAA IIIIIIIIIIIIIAAA JJJJJJJJJJJJJAAA KKKKKKKKKKKKKAAA LLLLLLLLLLLLLAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA

This example shows the same selection of grids as the previous display, but now I've used my scripts to remove all but one of the layers (the one I had named the "blocks" layer). Visually, the layer appears to consist of four sections. Two of the sections are just unencrypted As. In the bottom three rows, where the key begins with 89, the top colored section is unaffected by changes to d, while the bottom colored section increases as d increases. (Note that the meaning of the green and red colors are reversed from how they were in the previous example.) But then the two colored sections seem to trade places in the top row, where the key begins with 88 instead. You can also see that the position of the bottom section is shifted by one position in the lower rows, but the top one doesn't move. Little things like these are what made the calculations for the layer so complicated.

8891             8892             8893             8894             8895             8896             8897             8898             8899
AAAZZZZAAAARRRRA AAAZZZZAAAASSSSA AAAZZZZAAAATTTTA AAAZZZZAAAAUUUUA AAAZZZZAAAAVVVVA AAAZZZZAAAAWWWWA AAAZZZZAAAAXXXXA AAAZZZZAAAAYYYYA AAAZZZZAAAAZZZZA
AAAZZZZAAAARRRRA AAAZZZZAAAASSSSA AAAZZZZAAAATTTTA AAAZZZZAAAAUUUUA AAAZZZZAAAAVVVVA AAAZZZZAAAAWWWWA AAAZZZZAAAAXXXXA AAAZZZZAAAAYYYYA AAAZZZZAAAAZZZZA
AAAZZZZAAAARRRRA AAAZZZZAAAASSSSA AAAZZZZAAAATTTTA AAAZZZZAAAAUUUUA AAAZZZZAAAAVVVVA AAAZZZZAAAAWWWWA AAAZZZZAAAAXXXXA AAAZZZZAAAAYYYYA AAAZZZZAAAAZZZZA
AAAZZZZAAAARRRRA AAAZZZZAAAASSSSA AAAZZZZAAAATTTTA AAAZZZZAAAAUUUUA AAAZZZZAAAAVVVVA AAAZZZZAAAAWWWWA AAAZZZZAAAAXXXXA AAAZZZZAAAAYYYYA AAAZZZZAAAAZZZZA
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
8911             8912             8913             8914             8915             8916             8917             8918             8919
AAAHHHHAAAAIIIIA AAAIIIIAAAAIIIIA AAAJJJJAAAAIIIIA AAAKKKKAAAAIIIIA AAALLLLAAAAIIIIA AAAMMMMAAAAIIIIA AAANNNNAAAAIIIIA AAAOOOOAAAAIIIIA AAAPPPPAAAAIIIIA
AAAHHHHAAAAIIIIA AAAIIIIAAAAIIIIA AAAJJJJAAAAIIIIA AAAKKKKAAAAIIIIA AAALLLLAAAAIIIIA AAAMMMMAAAAIIIIA AAANNNNAAAAIIIIA AAAOOOOAAAAIIIIA AAAPPPPAAAAIIIIA
AAAHHHHAAAAIIIIA AAAIIIIAAAAIIIIA AAAJJJJAAAAIIIIA AAAKKKKAAAAIIIIA AAALLLLAAAAIIIIA AAAMMMMAAAAIIIIA AAANNNNAAAAIIIIA AAAOOOOAAAAIIIIA AAAPPPPAAAAIIIIA
AAAHHHHAAAAIIIIA AAAIIIIAAAAIIIIA AAAJJJJAAAAIIIIA AAAKKKKAAAAIIIIA AAALLLLAAAAIIIIA AAAMMMMAAAAIIIIA AAANNNNAAAAIIIIA AAAOOOOAAAAIIIIA AAAPPPPAAAAIIIIA
AAAHHHHAAAAAIIII AAAIIIIAAAAAIIII AAAJJJJAAAAAIIII AAAKKKKAAAAAIIII AAALLLLAAAAAIIII AAAMMMMAAAAAIIII AAANNNNAAAAAIIII AAAOOOOAAAAAIIII AAAPPPPAAAAAIIII
AAAAHHHHAAAAIIII AAAAIIIIAAAAIIII AAAAJJJJAAAAIIII AAAAKKKKAAAAIIII AAAALLLLAAAAIIII AAAAMMMMAAAAIIII AAAANNNNAAAAIIII AAAAOOOOAAAAIIII AAAAPPPPAAAAIIII
AAAAHHHHAAAAIIII AAAAIIIIAAAAIIII AAAAJJJJAAAAIIII AAAAKKKKAAAAIIII AAAALLLLAAAAIIII AAAAMMMMAAAAIIII AAAANNNNAAAAIIII AAAAOOOOAAAAIIII AAAAPPPPAAAAIIII
AAAAHHHHAAAAIIII AAAAIIIIAAAAIIII AAAAJJJJAAAAIIII AAAAKKKKAAAAIIII AAAALLLLAAAAIIII AAAAMMMMAAAAIIII AAAANNNNAAAAIIII AAAAOOOOAAAAIIII AAAAPPPPAAAAIIII
8921             8922             8923             8924             8925             8926             8927             8928             8929
AAATTTTAAAAVVVVA AAAUUUUAAAAVVVVA AAAVVVVAAAAVVVVA AAAWWWWAAAAVVVVA AAAXXXXAAAAVVVVA AAAYYYYAAAAVVVVA AAAZZZZAAAAVVVVA AAAAAAAAAAAVVVVA AAABBBBAAAAVVVVA
AAATTTTAAAAVVVVA AAAUUUUAAAAVVVVA AAAVVVVAAAAVVVVA AAAWWWWAAAAVVVVA AAAXXXXAAAAVVVVA AAAYYYYAAAAVVVVA AAAZZZZAAAAVVVVA AAAAAAAAAAAVVVVA AAABBBBAAAAVVVVA
AAATTTTAAAAVVVVA AAAUUUUAAAAVVVVA AAAVVVVAAAAVVVVA AAAWWWWAAAAVVVVA AAAXXXXAAAAVVVVA AAAYYYYAAAAVVVVA AAAZZZZAAAAVVVVA AAAAAAAAAAAVVVVA AAABBBBAAAAVVVVA
AAATTTTAAAAVVVVA AAAUUUUAAAAVVVVA AAAVVVVAAAAVVVVA AAAWWWWAAAAVVVVA AAAXXXXAAAAVVVVA AAAYYYYAAAAVVVVA AAAZZZZAAAAVVVVA AAAAAAAAAAAVVVVA AAABBBBAAAAVVVVA
AAATTTTAAAAAVVVV AAAUUUUAAAAAVVVV AAAVVVVAAAAAVVVV AAAWWWWAAAAAVVVV AAAXXXXAAAAAVVVV AAAYYYYAAAAAVVVV AAAZZZZAAAAAVVVV AAAAAAAAAAAAVVVV AAABBBBAAAAAVVVV
AAAATTTTAAAAVVVV AAAAUUUUAAAAVVVV AAAAVVVVAAAAVVVV AAAAWWWWAAAAVVVV AAAAXXXXAAAAVVVV AAAAYYYYAAAAVVVV AAAAZZZZAAAAVVVV AAAAAAAAAAAAVVVV AAAABBBBAAAAVVVV
AAAATTTTAAAAVVVV AAAAUUUUAAAAVVVV AAAAVVVVAAAAVVVV AAAAWWWWAAAAVVVV AAAAXXXXAAAAVVVV AAAAYYYYAAAAVVVV AAAAZZZZAAAAVVVV AAAAAAAAAAAAVVVV AAAABBBBAAAAVVVV
AAAATTTTAAAAVVVV AAAAUUUUAAAAVVVV AAAAVVVVAAAAVVVV AAAAWWWWAAAAVVVV AAAAXXXXAAAAVVVV AAAAYYYYAAAAVVVV AAAAZZZZAAAAVVVV AAAAAAAAAAAAVVVV AAAABBBBAAAAVVVV
8931             8932             8933             8934             8935             8936             8937             8938             8939
AAADDDDAAAAGGGGA AAAEEEEAAAAGGGGA AAAFFFFAAAAGGGGA AAAGGGGAAAAGGGGA AAAHHHHAAAAGGGGA AAAIIIIAAAAGGGGA AAAJJJJAAAAGGGGA AAAKKKKAAAAGGGGA AAALLLLAAAAGGGGA
AAADDDDAAAAGGGGA AAAEEEEAAAAGGGGA AAAFFFFAAAAGGGGA AAAGGGGAAAAGGGGA AAAHHHHAAAAGGGGA AAAIIIIAAAAGGGGA AAAJJJJAAAAGGGGA AAAKKKKAAAAGGGGA AAALLLLAAAAGGGGA
AAADDDDAAAAGGGGA AAAEEEEAAAAGGGGA AAAFFFFAAAAGGGGA AAAGGGGAAAAGGGGA AAAHHHHAAAAGGGGA AAAIIIIAAAAGGGGA AAAJJJJAAAAGGGGA AAAKKKKAAAAGGGGA AAALLLLAAAAGGGGA
AAADDDDAAAAGGGGA AAAEEEEAAAAGGGGA AAAFFFFAAAAGGGGA AAAGGGGAAAAGGGGA AAAHHHHAAAAGGGGA AAAIIIIAAAAGGGGA AAAJJJJAAAAGGGGA AAAKKKKAAAAGGGGA AAALLLLAAAAGGGGA
AAADDDDAAAAAGGGG AAAEEEEAAAAAGGGG AAAFFFFAAAAAGGGG AAAGGGGAAAAAGGGG AAAHHHHAAAAAGGGG AAAIIIIAAAAAGGGG AAAJJJJAAAAAGGGG AAAKKKKAAAAAGGGG AAALLLLAAAAAGGGG
AAAADDDDAAAAGGGG AAAAEEEEAAAAGGGG AAAAFFFFAAAAGGGG AAAAGGGGAAAAGGGG AAAAHHHHAAAAGGGG AAAAIIIIAAAAGGGG AAAAJJJJAAAAGGGG AAAAKKKKAAAAGGGG AAAALLLLAAAAGGGG
AAAADDDDAAAAGGGG AAAAEEEEAAAAGGGG AAAAFFFFAAAAGGGG AAAAGGGGAAAAGGGG AAAAHHHHAAAAGGGG AAAAIIIIAAAAGGGG AAAAJJJJAAAAGGGG AAAAKKKKAAAAGGGG AAAALLLLAAAAGGGG
AAAADDDDAAAAGGGG AAAAEEEEAAAAGGGG AAAAFFFFAAAAGGGG AAAAGGGGAAAAGGGG AAAAHHHHAAAAGGGG AAAAIIIIAAAAGGGG AAAAJJJJAAAAGGGG AAAAKKKKAAAAGGGG AAAALLLLAAAAGGGG

This example is showing the exact same row as the previous one, but this time I've also applied the first stage of the reordering algorithm. Now the two sections are broken up into chunks of four positions each (thus forming vertical stripes in our square display). This makes it a little more regular, since we have a space of four positions, then four of the incrementing section, then another space of four, then four of the static section, and then it repeats. Except now there's this one little spot in the middle where there is a space of five positions. So, in balance, it's not much of an improvement.

8891             8892             8893             8894             8895             8896             8897             8898             8899
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
AAAAZZZZAAAARRRR AAAAZZZZAAAASSSS AAAAZZZZAAAATTTT AAAAZZZZAAAAUUUU AAAAZZZZAAAAVVVV AAAAZZZZAAAAWWWW AAAAZZZZAAAAXXXX AAAAZZZZAAAAYYYY AAAAZZZZAAAAZZZZ
8911             8912             8913             8914             8915             8916             8917             8918             8919
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
AAAAIIIIAAAAHHHH AAAAIIIIAAAAIIII AAAAIIIIAAAAJJJJ AAAAIIIIAAAAKKKK AAAAIIIIAAAALLLL AAAAIIIIAAAAMMMM AAAAIIIIAAAANNNN AAAAIIIIAAAAOOOO AAAAIIIIAAAAPPPP
8921             8922             8923             8924             8925             8926             8927             8928             8929
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
AAAAVVVVAAAATTTT AAAAVVVVAAAAUUUU AAAAVVVVAAAAVVVV AAAAVVVVAAAAWWWW AAAAVVVVAAAAXXXX AAAAVVVVAAAAYYYY AAAAVVVVAAAAZZZZ AAAAVVVVAAAAAAAA AAAAVVVVAAAABBBB
8931             8932             8933             8934             8935             8936             8937             8938             8939
AAAAGGGGAAAADDDD AAAAGGGGAAAAEEEE AAAAGGGGAAAAFFFF AAAAGGGGAAAAGGGG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GAAAAIIII AAAAGGGGAAAAJJJJ AAAAGGGGAAAAKKKK AAAAGGGGAAAALLLL

This display shows the layer after applying two of the four stages of reordering. As you can see, the irregularity is gone now, showing that it was purely a side effect of the back-to-front shuffling that took place during that step. Notice also that the two sections are in the same order throughout. The swap that occurred before was entirely due to the shifting part of this reordering phase. Clearly, this layer of the encryption process took place immediately after the first two phases of the reordering.

In this fashion, I quickly identified the most natural point in the reordering process to apply each of my layers. Doing this allowed me to simplify the calculations for some of them. However, I found to my surprise and frustration, that I was only able to consolidate one or two of them. That still left me with eight layers, some of which were only applied to certain sizes of grids. And though they had been simplified, they still didn't display the invariants that I had discovered (i.e. it was not obvious that subtractions would ultimately cancel out, and that the coefficients would always add up to four). For the most part, my hopes that this would "fix" the rampaging ugliness in my encryption algorithm was unmet.

The fact that the coefficients always sum to four, coupled with the fact that the reordering process occurs in four phases, strongly argued that the encryption process also ran in four phases, with each phase adding exactly one digit to each position. But that looked nothing like my current separation of layers, and it wasn't at all clear that they could be juggled around to fit. Still, the model was so compelling, I kept hammering at it, trying to find a way to make it fit.

You may recall the first layer I identified, the one I referred to earlier as the "underlying quartet". It was just a sequence of four values that repeated in a loop. The sequence was simplicity itself, but the calculations were ugly and complex. If my new pet theory was correct, then the underlying quartet would actually have to contain a little bit of every other layer mixed in as well. (Which would explain why I was having so much trouble getting the other layers to fit together.) You may also recall that the formulas for the underlying quartet's values change depending on the grid's size modulo four. A majority of my layers had that annoying feature, in fact.

But now, this is what the underlying quartet layer looks like after the first phase of the reordering.

8891             8892             8893             8894             8895             8896             8897             8898             8899
HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
BBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCC DDDDDDDDDDDDDDDD EEEEEEEEEEEEEEEE FFFFFFFFFFFFFFFF GGGGGGGGGGGGGGGG HHHHHHHHHHHHHHHH IIIIIIIIIIIIIIII JJJJJJJJJJJJJJJJ
HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
BBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCC DDDDDDDDDDDDDDDD EEEEEEEEEEEEEEEE FFFFFFFFFFFFFFFF GGGGGGGGGGGGGGGG HHHHHHHHHHHHHHHH IIIIIIIIIIIIIIII JJJJJJJJJJJJJJJJ
8911             8912             8913             8914             8915             8916             8917             8918             8919
SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSS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 KKKKKKKKKKKKKKKK LLLLLLLLLLLLLLLL MMMMMMMMMMMMMMMM
8921             8922             8923             8924             8925             8926             8927             8928             8929
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV
UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU
NNNNNNNNNNNNNNNN OOOOOOOOOOOOOOOO PPPPPPPPPPPPPPPP QQQQQQQQQQQQQQQQ RRRRRRRRRRRRRRRR SSSSSSSSSSSSSSSS TTTTTTTTTTTTTTTT UUUUUUUUUUUUUUUU VVVVVVVVVVVVVVVV
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVV
UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUU
NNNNNNNNNNNNNNNN OOOOOOOOOOOOOOOO PPPPPPPPPPPPPPPP QQQQQQQQQQQQQQQQ RRRRRRRRRRRRRRRR SSSSSSSSSSSSSSSS TTTTTTTTTTTTTTTT UUUUUUUUUUUUUUUU VVVVVVVVVVVVVVVV
8931             8932             8933             8934             8935             8936             8937             8938             8939
WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW
SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS
RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR
KKKKKKKKKKKKKKKK LLLLLLLLLLLLLLLL MMMMMMMMMMMMMMMM NNNNNNNNNNNNNNNN OOOOOOOOOOOOOOOO PPPPPPPPPPPPPPPP QQQQQQQQQQQQQQQQ RRRRRRRRRRRRRRRR SSSSSSSSSSSSSSSS
WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW
SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS
RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRR
KKKKKKKKKKKKKKKK LLLLLLLLLLLLLLLL MMMMMMMMMMMMMMMM NNNNNNNNNNNNNNNN OOOOOOOOOOOOOOOO PPPPPPPPPPPPPPPP QQQQQQQQQQQQQQQQ RRRRRRRRRRRRRRRR SSSSSSSSSSSSSSSS

When looked at this way, the repeating sequence of four values applied to single positions instead becomes a repeating sequence of four regions, each region being sixteen positions wide. A very small change, and not necessarily simpler — except that I finally realized that the regions of sixteen would then be the same for all grid sizes, even and odd alike.

That insight really simplified that layer. I figured it would probably also help simplify the others, but I never got to that point. Once I started viewing this layer as being made up of regions, each one sixteen positions wide, I realized that I could describe almost all of my layers as being made up of regions of different sizes, with the size being either sixteen, eight, four, or two....

The parallel with the reordering was too great to ignore. I tried this pattern out with my pet theory, and suddenly it all fell into place. The encryption could be rearranged as four layers, one layer applied after each phase of the reordering process. Each layer of the encryption was made up of four regions applied in sequence, over and over, and each region just being the addition of one of the digits from the key.

The Scrambling Process: For Real This Time

No, really. That's the whole thing. Start out with a collection of grids of all As:

8891             8892             8893             8894             8895             8896             8897             8898             8899
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
8911             8912             8913             8914             8915             8916             8917             8918             8919
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAA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AAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
8921             8922             8923             8924             8925             8926             8927             8928             8929
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
8931             8932             8933             8934             8935             8936             8937             8938             8939
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA

The first phase of the encryption applies each of the digits of the key in succession, repeating until the grid is filled. After reordering, the grid regions of width sixteen have been completely intermixed, so that they look like regions of width one.

8891             8892             8893             8894             8895             8896             8897             8898             8899
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
IIJBIIJBIIJBIIJIIJCIIJCIIJCIIJIIJDIIJDIIJDIIJIIJEIIJEIIJEIIJIIJFIIJFIIJFIIJIIJGIIJGIIJGIIJIIJHIIJHIIJHIIJIIJIIIJIIIJIIIJIIJJIIJJIIJJIIJJ
8911             8912             8913             8914             8915             8916             8917             8918             8919
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
IJBBIJBBIJBBIJBIJBCIJBCIJBCIJBIJBDIJBDIJBDIJBIJBEIJBEIJBEIJBIJBFIJBFIJBFIJBIJBGIJBGIJBGIJBIJBHIJBHIJBHIJBIJBIIJBIIJBIIJBIJBJIJBJIJBJIJBJ
8921             8922             8923             8924             8925             8926             8927             8928             8929
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
IJCBIJCBIJCBIJCIJCCIJCCIJCCIJCIJCDIJCDIJCDIJCIJCEIJCEIJCEIJCIJCFIJCFIJCFIJCIJCGIJCGIJCGIJCIJCHIJCHIJCHIJCIJCIIJCIIJCIIJCIJCJIJCJIJCJIJCJ
8931             8932             8933             8934             8935             8936             8937             8938             8939
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ
IJDBIJDBIJDBIJDIJDCIJDCIJDCIJDIJDDIJDDIJDDIJDIJDEIJDEIJDEIJDIJDFIJDFIJDFIJDIJDGIJDGIJDGIJDIJDHIJDHIJDHIJDIJDIIJDIIJDIIJDIJDJIJDJIJDJIJDJ

The second phase of encryption does the same thing with regions only half as wide. But since it gets applied at a later phase of the reordering process, the regions don't line up with the regions from the first encryption phase, and thus a bit of chaos is introduced.

8891             8892