# Solution for the "Rogue submarine riddle"

I was watching this video about a "Rogue submarine riddle" and wondering about the first part of the solution for the problem. The idea is that you have two people $$A$$ and $$B$$ that are given codes and the "boss" who gave the codes then spits out the following paragraph

I chose a set of distinct positive integers with at least two elements, each less than $$7$$, and told their sum to you, $$A$$, and their product to you, $$B$$.”

After a moment of awkward silence, $$A$$ says to $$B$$, “I don’t know whether you know my number.” $$B$$ thinks this over, then responds, “I know your number, and now I know you know my number too.”

In the solution the explainer states that

The only scenarios where $$B$$ could know $$A$$'s number is when there is exactly one way to factor $$B$$'s number.

He then states that the "pattern" here is that $$B$$'s number must be a prime of the square of a prime.

I don't quite understand why is this the case? $$B$$'s number can be anything of the form $$nk$$, where $$1 \le n,k\le 6$$ so how can we reduce this to the case where the number must be either a prime or a square of a prime?

• One complicating issue is that $1$ is allowed as a factor. Thus, for instance, $8$ does not settle the issue for $B$. $8$ could be the result of $2\times 4$ or it could be the result of $1\times 2\times 4$. (it can't be $1\times 8$ because $8$ is too big, and it can't be $2\times 2\times 2$ because the factors must be distinct). No way for $B$ to tell, without more information.
– lulu
Jul 2 at 23:58

A's sum number is at least $$1+ 2=3$$ and B's product number is at least $$1\times 2=2$$. Similarly A's sum number is no more than $$1+2+3+4+5+6=21$$ and A's sum number is no more than $$1 \times2 \times3 \times4 \times5 \times6=720$$. But B having a product number of $$720$$ would not tell B what A's sum number was, as it could be $$21$$ or it could be $$2+3+4+5+6=20$$. Developing this idea:

• If B's product number were prime i.e. $$p$$ then $$B$$ would know that is was the product $$1 \times p$$ and so would know A's sum number was $$1+p$$

• If B's product number were the square of a prime i.e. $$p^2$$ then $$B$$ would know that is was the product $$1 \times p^2$$ (it could not be $$p \times$$ something as that something would include multiplying by a second $$p$$) and so would know A's sum number was $$1+p^2$$

• If B's product number were some other number, say $$ab$$ with $$2\le a \le b$$ then $$B$$ would not know whether it was $$a\times b$$ or $$1 \times a \times b$$ (and in some cases there would be further possibilities) and so would not know whether A's sum number was $$a+b$$ or $$1+a+b$$ (or possibly something else)

So if A (knowing the sum number) cannot tell whether or not B can work out the sum number, then the sum number must allow a product number which is prime or the square of a prime (in which case B can work out A's sum number) and must allow a product number which is neither (in which case B cannot work out A's sum number). A's initial thinking is:

• A sum number of $$3$$ would not do as the only product number would be $$1\times 2=2$$ allowing B to work out the sum number is $$1 + 2$$
• A sum number of $$4$$ would not do as the only product number would be $$1\times 3=3$$ allowing B to work out the sum number is $$1 + 3$$
• A sum number of $$5$$ would do as the product number could be $$1\times 4=4$$ allowing B to work out the sum number is $$1 + 4=4$$, or the product number could be $$2 \times 3=1\times 2 \times 3=6$$ not allowing B to work out whether the sum number is $$2 + 3=5$$ or $$1+2 + 3=6$$
• A sum number of $$6$$ would do as the product number could be $$1\times 5=5$$ allowing B to work out the sum number is $$1 + 5=6$$, or the product number could be $$1\times 2 \times 3=6$$ not allowing B to work out whether the sum number is $$2 + 3=5$$ or $$1+2 + 3=6$$, or the product number could be $$2 \times 4=8$$ not allowing B to work out whether the sum number is $$2 + 4=6$$ or $$1+2 + 4=7$$
• A sum number of $$7$$ would not do as the product number could be $$1\times 6=6$$ or $$1\times2\times4 =8$$ or $$2 \times 5=10$$ or $$3 \times 4=10$$, none of which are prime or the square of a prime (put another way, $$7$$ is not $$1$$ more than a prime or $$1$$ more than the square of a prime), so A knows that B cannot work out the sum number from the product number.
• Any larger sum number that is actually possible with elements less than $$7$$ runs into the same issue

So from A's initial statement we know that the sum number must be $$5$$ or $$6$$. Importantly for the rest of the puzzle, not only do we know that B know this, but also that B also knows that A knows B knows.