# Deciphering a number system

If I were to say that:

2    +   2   =   22
2    +   q   =   q2
q    +   2   =   q2
22   +   q2  =   q22
2q2  +   q   =   q2q
qqq  +   22  =   qq22

2    x   2   =   22
2    x   q   =   2q
q    x   2   =   2q
2q   x   q   =   2q22
q2q  x   q2  =   q22222
qq   x   qq  =   q222q


could you then tell me what 2qq2 x qq2 is?

Some notes:

• the 'x' in the above is ordinary mathematical multiplication, the '+' is addition, and the '=' is equality.
• each string of 2's and q's is a natural number. Every string is a number, and every number except 0 is a string (including the empty string).
• you do not need every piece of information in the box to determine an answer, though the answer will be consistent with every piece of information in the box.

Since someone got a correct answer, using different reasoning than I did, I'll add my own reasoning below for those who are interested:

First off, the empty string is 1. If some string x corresponds to some integer $n$, then 2x corresponds to $2n$ and qx corresponds to $2n + 1$. So 2 = $2 \times 1$ = $2$, q = $2 \times 1 + 1$ = $3$ and so on. qq2 = $2 \times (2 \times 2 + 1) + 1$ = 11, and 2qq2 thus = $2 \times 11$ = $22$, the product of which is $242$ = $2 \times (2 \times (2 \times (2 \times (2 \times (2 \times (2 + 1) + 1) + 1))) + 1)$ = 2q22qqq.

• Would you like to tell us whether every natural number is representable by some string of 2s and qs? (Feel free not to.) – Gareth McCaughan Jul 8 '16 at 17:12
• Indeed every natural number is representable, if you include the empty string and don't include 0 as a natural number. My apologies for the omission, that one slipped past me. – P... Jul 8 '16 at 17:13
• At the risk of being petty and/or splitting hairs: if, as you say, '+' and 'x' are ordinary addition and multiplication, then $a+b=b+a$ and $a\times b=b\times a$ for all $a$ and $b$, so you didn't really need to tell us that $2+q=q+2$ and $2\times q=q\times 2$ — or am I misunderstanding something? – Peregrine Rook Jul 8 '16 at 17:21
• I don't think you are misunderstanding anything. I put those in for clarity's sake, and to demonstrate that there aren't different 'rules' for translating strings based just on their position in the line. Perhaps unnecessary, but a bit of redundancy never hurt anyone. – P... Jul 8 '16 at 17:29
• OK. Are you sure $\rm 2q2+q=q22q$? I've got a decipherment that works for every line except that one. – Peregrine Rook Jul 8 '16 at 17:36

2q22qqq

The system:

Replace 2 with $0$ and q with $1$.  Add another $1$ at the end, then reverse the order of the string of bits and interpret it as a binary integer.  For example,
2 = $\phantom{00}10 = \phantom{0}2$
22 = $\phantom{0}100 = \phantom{0}4$
222 = $1000 = \phantom{0}8$, etc.
q = $\phantom{00}11 = \phantom{0}3$
qq = $\phantom{0}111 = \phantom{0}7$
qqq = $1111 = 15$, etc.
q2 = $\phantom{0}101 = \phantom{0}5$
2q = $\phantom{0}110 = \phantom{0}6$, and so on.

How I determined this answer:

Given that we are talking about ordinary addition and multiplication, and only the numbers are enciphered, I can say that, for any aa+a =$2~\times$a, a+a+a= $3~\times$a, a+a+a+a =$4~\times$a, etc.  So 2+2 equals $2~\times$2.  But 2+2 = 2×2, so 2 equals $2$.

2+2 = 2×2 = 22, so 22 equals $4$.

q ≠$0$, because if q =$0$, then 2+q (which equals q+2 by the commutative property of addition) would equal 2.  (Also, the OP suggested that $0$ was not representable.)  q ≠$1$, because if q =$1$, then 2×q (which equals q×2 by the commutative property of multiplication) would equal 2.  I interpreted the OP’s comment that “every natural number is representable” to mean “every natural number is representable uniquely”, so q ≠ 2($2$) and q ≠$4$.  I guessed that maybe q was $3$, which led to the conclusion that 2+q = $2+3=5$, so q2 must be $5$, and 2×q = $2\times 3=6$, so 2q must be $6$.  So, I had
2 = $2$
q = $3$
22 = $4$
q2 = $5$
2q = $6$
(some of which were guesses).  Between that, and the OP’s hint that some number might be representable as an empty string, I guessed the rest.  All the given equations are (now) consistent with this scheme.

# The specific question:

2qq2 = $10110 = 22$
qq2 = $\phantom{0}1011 = 11$

Working in binary:\begin{align}10110\\\times\qquad 1011\\\hline10110\\10110\phantom{0}\\+~~10110\phantom{000}\\\hline11110010\end{align} Working in decimal: $22 \times 11 = 242 = 128 + 64 + 32 + 16 + 2 = 11110010_2$

Either way, strip off the leading $1$ and reverse the remaining bits to get $0100111 \leftrightarrow$ 2q22qqq.

• Your explanation does work, though It's not what I originally thought of (which I may add to the question in a spoiler later) but your answer to the specific question is incorrect. Take a look at the first line of your last spoiler block... – P... Jul 8 '16 at 19:20
• There you go! Accepted, and edit to question explaining my own reasoning coming shortly. – P... Jul 8 '16 at 19:40
• Sigh; nobody's perfect.     :-)     Thanks for the nudge. – Peregrine Rook Jul 8 '16 at 19:40