```Edgardo Hames wrote:
> On Apr 10, 2005 8:45 PM, Zach Dennis <zdennis / mktec.com> wrote:
>
>>I have the following table of data, and I am looking to create an
>>equation to recreate the table. If anyone finds this sort of thing fun,
>>or has a online resource or a good book that helps explaining these
>>types of math concepts, please take a stab at it or post any info that
>>might aide me in my discovery! I've been trying the past several hours
>>and this sort of thing isn't my strong suit...and i'm stuck!
>>
>>I am first looking to understand how-to make the pattern of data into a
>>actual math equation...then from there I'd like to write ruby code for
>>the equation.
>>
>>Here is the sample data in a table:
>>        - rows represent a different character (as labeled)
>>        - columns represent the position of the character
>>          (examples represent data in decimal notation, not octal/hex)
>>                example: "aaaa" would become 000 003 002 005
>>                example: "zach" would become 027 003 000 012
>>
>>        1       2       3       4       5       6    (etc......)
>>----------------------------------------------------
>>a 1   | 0       3       2       5       4       7
>>b 2   | 3       0       1       6       7       4
>>c 3   | 2       1       0       7       6       5
>>d 4   | 5       6       7       0       1       2
>>e 5   | 4       7       6       1       0       3
>>f 6   | 7       4       5       2       3       0
>>g 7   | 6       5       4       3       2       1
>>h 8   | 9       10      11      12      13      14
>>i 9   | 8       11      10      13      12      15
>>j 10  | 11      8       9       14      15      12
>>k 11  | 10      9       8       15      14      13
>>l 12  | 13      14      15      8       9       10
>>m 13  | 12      15      14      9       8       11
>>n 14  | 15      12      13      10      11      8
>>o 15  | 14      13      12      11      10      9
>>p 16  | 17      18      19      20      21      22
>>q 17  | 16      19      18      21      20      23
>>r 18  | 19      16      17      22      23      20
>>s 19  | 18      17      16      23      22      21
>>t 20  | 21      22      23      16      17      18
>>u 21  | 20      23      22      17      16      19
>>v 22  | 23      20      21      18      19      16
>>w 23  | 22      21      20      19      18      17
>>x 24  | 25      26      27      28      29      30
>>y 25  | 24      27      26      29      28      31
>>z 26  | 27      24      25      30      31      28
>>
>
>
> First, I transposed the table since the text editor works best across lines not
> columns ;) I looked at the deltas between the columns and the natural sequence
> of numbers and I found an interesting pattern.  I will attempt to give you an
> explanation of what I came up with, and I hope it's in any way helpful.
>
> For columns numbered with a power of two (1, 2, 4, 8, 16, ...) the deltas are
> the power of two alternating its sign +/-.
> It's rather difficult to explain, so please, take a look at the following table:
>
> Input       1  2  3  4  5  6  7  8  9  10 11 12
>            -----------------------------------
> Col 1      -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1
> Col 2      +2 -2 -2 +2 +2 -2 -2 +2 -2 -2 +2 +2
> Col 4      +4 +4 +4 -4 -4 -4 -4 +4 +4 +4 +4 -4
> Col 8      +8 +8 +8 +8 +8 +8 +8 -8 -8 -8 -8 -8
>
> The sign is positive until you reach the given power of two, then it changes to
> negative for that power of two times and will keep changing back and forth (it
> may help you trying to complete some other values on my table, since I don't
> know whether I make myself clear).
>
> The values for the deltas on the other columns is a combination of these
> previous columns (just like any number can be expressed as a sum of some powers
> of two) For example, on column 3, the delta equals the delta on col 1 plus the
> delta on col 2. Take a look:
>
> Col 1      -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1
> Col 2      +2 -2 -2 +2 +2 -2 -2 +2 -2 -2 +2 +2
> -----------------------------------------------
> Col 3      +1 -1 -3 +3 +1 -1 -3 +3 -3 -1 +1 +3
>
> Column 5 can be calculated based on col 1 + col 4 (5 = 0101)
>
> Col 1      -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1
> Col 4      +4 +4 +4 -4 -4 -4 -4 +4 +4 +4 +4 -4
> -----------------------------------------------
> Col 5      +3 +5 +3 -3 -5 -3 -5 +5 +3 +5 +3 -3
>
> Column 6 can be calculated based on col 2 + col 4 (6 = 0110)
>
> Col 2      +2 -2 -2 +2 +2 -2 -2 +2 -2 -2 +2 +2
> Col 4      +4 +4 +4 -4 -4 -4 -4 +4 +4 +4 +4 -4
> -----------------------------------------------
> Col 6      +6 +2 +2 -2 -2 -6 -6 +6 +2 +2 +6 -2
>
> Column 7 can be calculated based on col 1 + col 2 + col 4 (7 = 0111)
>
> Col 1      -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1
> Col 2      +2 -2 -2 +2 +2 -2 -2 +2 -2 -2 +2 +2
> Col 4      +4 +4 +4 -4 -4 -4 -4 +4 +4 +4 +4 -4
> -----------------------------------------------
> Col 7      +5 +3 +1 -1 -3 -5 -7 +7 +1 +3 +5 -1
>
> Column 9 is no exception. Take column 1 and 8 and add them (9 = 1001)
>
> Col 1      -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1
> Col 8      +8 +8 +8 +8 +8 +8 +8 -8 -8 -8 -8 -8
> -----------------------------------------------
> Col 9      +7 +9 +7 +9 +7 +9 +7 -7 -9 -7 -9 -7
>
> I guess you can write a formula for the table based on this
> explanation (which I hope was clear enough). If you need further
> assistance, I'll be keeping an eye on this thread. I think it was an
> interesting problem, very well suited for a Ruby Quiz ;)

Edgardo...

Thank you for your reply. The patterns found in this table is really
weird. I found 2 patterns myself, and then you found a completely
different one. Now that I know that it's an xor that is causing this, I
will be able to recognize these types of patterns in the future. Thanks
for your post and for your explanation. If I come up with any other
pattern/algorithmic type of problems I will be sure to send it to James
Edward Gray for a Ruby Quiz.,

Zach

```