# The Pattern-Bot

This is an entry into the 20th fortnightly topic challenge.

Over the past few days, I have been receiving a series of strange emails. I wonder if you could tell me what they are:

Email 1:

Sender: patternbot1@gmail.com

Subject: 1

1: 1 1 1

Email 2:

Sender: patternbot2@gmail.com

Subject: 2

3: 1 2 2

2: 1 1 1 2 2

Email 3:

Sender: patternbot8@gmail.com

Subject: 10

6: 0 0 0 0

7: 2 2 3 2

5: 1 2 2

Email 4:

Sender: patternbot3@gmail.com

Subject: 11

4: 0 0 0 0 0

12: 1 2 2 3 4

Email 5:

Sender: patternbot6@gmail.com

Subject: 12

13: 1 2 2 3

Email 6:

Sender: patternbot9@gmail.com

Subject: 20

15: 1 2 2

14: 2 4 4 8 9 18

Email 7:

Sender: patternbot17@gmail.com

Subject: 100

10: 1 1 1 1 1 1

11: 2 4 4 8 10 20 30 56

9: 0 1 1 2 2 4 5 10

Email 8:

Sender: patternbot4@gmail.com

Subject: 101

8: 4 5 7 7 8 9 11

24: 1 1 2 2 4 6 10

25: 0 0 2 2 4 8 16 12 48

27: 2 2 4 8 13 25 44 83

Email 9:

Sender: patternbot20@gmail.com

Subject: 102

26: 2 2 5 4 7 7 11 9

30: 1 2 2 6 6 18

Email 10:

Sender: patternbot7@gmail.com

Subject: 110

31: 2 6 9 17 30 54 98 183 341

For clarification, I think I have provided enough information so that this is not a 'guess what I'm thinking' type of puzzle.

I will release more emails every now and again, depending on the progress everyone is making.

In an answer, I expect an explanation of how the emails are generated, and also what the next email should be.

• In a particular email, is the message body 'maximal'? In other words, in (say) Email 9, could there be any numbers other than 26 and 30 which could possibly start rows in that email, and could either of the existing rows possibly be extended any further? – Rand al'Thor Nov 20 '16 at 0:56
• @randal'thor The message body is maximal in the sense that what goes in the message is strictly defined. – boboquack Nov 20 '16 at 0:58
• May I ask, why the downvotes? I know I've got two. – boboquack Nov 20 '16 at 1:52

The next email will be:

Sender: patternbot15@gmail.com

Subject: 111

29: 1 1 2 2 6 9 20 37 86
28: 8 8 112 656 5504 49024 491264 5401856 64826368 842734592 11798300672

Going by natural numbers:

the sender number, $15$, is the next count of iterations plus one in the Collatz sequence (A008908), although A050077 also fits for $54$.

The subject, $111$, is the next skew binary number (A169683).

The number of sequences, $2$, in the body is the number of letters in the Roman numerals of the next number (A006968). i.e. length("XI")=2

The left of the colon values, $29$ & $28$, are decimal values of Gray code (A003188)

The right of the colon values match terms in the sequences from the OEIS as enumerated by that website (i.e. A000001, A000002, A000003, ...).

The number of terms in the two next sequences, $9$ & $11$, are the number of alphabetic characters in the American English written form of the sequence number (A005589). i.e. length("twentytwo")=9, length("twentythree")=11

The sequences we have received so far start at indexes:
2,?,1,?,2,1,?,2,3,2,4,?,4,4,4,2,2,3,3,2,4
Where the ? represent values we cant be too sure of due to the sequence entries.
If we then add the index-offset (the value of n for which the first term of a sequence A(n) is defined) we get:
2,?,3,?,3,3,?,2,3,3,4,?,4,4,5,2,3,3,4,3,4

Then if we adjust that down by one to get the integer inputs to the functions the sequences are representing (since I counted "first" index "second" index etc... we get:
1,?,2,?,2,2,?,1,2,2,3,?,3,3,4,1,2,2,3,2,3

This matches the Hamming weight of the natural numbers (A000120 from the second entry) for which the next two values are $3$ and $4$.

Adjusting back by one and then the offsets ($0$ and $0$) then gives starting indexes of $4$ & $5$ and yields the sequences shown in the email above.

• Close... but not quite. There is one final hurdle that has eluded you. It is probably the most difficult one to find. – boboquack Nov 20 '16 at 1:36
• No, it wasn't the commas. I didn't notice myself and would have let that pass (it would have been the correct solution if so), and I would have just edited the commas out myself had it been the correct solution and I noticed. – boboquack Nov 20 '16 at 1:42
• Also, your solution doesn't fit for email 7, body line 3 – boboquack Nov 20 '16 at 1:45
• I noticed why it does not fit, but have not yet discovered the logic... – Jonathan Allan Nov 20 '16 at 1:56
• What doesn't fit in email 7, body line 3? It looks OK to me but I have probably miscounted something. (Or was there a mistake that has since been fixed?) – Gareth McCaughan Nov 20 '16 at 3:18

In the $n$th email, the sender is patternbot$m$@gmail.com where $m$ is the number of steps required to get from $n$ to $1$ using the $3n+1$ Collatz algorithm (see here).

For example, for the 6th email:

$6\rightarrow3\rightarrow10\rightarrow5\rightarrow16\rightarrow8\rightarrow4\rightarrow2\rightarrow1$: eight steps, so the sender is patternbot8@gmail.com.

It looks at first like these numbers ($1,2,10,11,12,20,\dots$) are written in ternary, but in fact

they're written in the skew binary system, in which the $k$th digit (starting digit indexing from zero) has a weight of $2^{k+1}-1$.

For example, for the 9th email:

$9=7+2=1*(2^3-1)+2*(2^1-1)$ is 102 in skew binary, so the subject header is 102.

WIP

## The next email

Email 11:

Sender: patternbot15@gmail.com

Subject: 111

[TBD]