Recently Ernie's twin niece and nephew Maria and Mario were spending a few days staying at his place. When I dropped in on a rainy Friday morning I found them a little dissatisfied with the arrangement. "Ernie cooks great food...", said Maria, "...and his stories are interesting, if a bit weird...", continued Mario, "...but he doesn't have any kids books..." (Maria), "...or games!" (Mario). I told them that I couldn't help with children's books, but might be able to find a few old games if they could come over for the afternoon. As Ernie had "stuff to do" he would arrive in time for dinner and to take them home later in the evening.

Back at my place, I fossicked through the spare-room cupboards until I stumbled on an old favorite - the game of Mastermind - a bit dusty, but none the worse for wear after goodness knows how many years in storage. Back when I was a school-child I had earned a bit of a reputation as an astute player. The children picked up the rules quickly and spent most of the afternoon in a battle-royale for Mastermind supremacy while I prepared dinner. Ernie arrived late in the afternoon as promised and to my surprise (I assumed Ernie would have known everything about games of logic) he didn't seem familiar with the game at all. "Mastermind?", he questioned, "Never heard of it". So of course the twins proposed a contest against him "We'll choose the secret code first" said Mario, as Ernie familiarized himself with the rules printed on the back of the box.

The first two turns went like this:

Ernie chose red, blue, yellow, purple (in that order), and Maria responded with "No hits and no misses".

Ernie then chose green, green, orange, orange (in that order), and Mario said "No hits but four misses".

To my surprise Ernie next chose yellow, orange, green, yellow. He stared hesitantly at the two 'hit' markers that Maria placed on the board and spent a long time before choosing red, red, red, blue for his next guess (his fingers were shaking slightly as he did so). To cut a long story short, Ernie took another seventeen turns before finally stumbling on the obvious orange, orange, green, green and the secret code was revealed.

"Time for dinner", I called, interrupting the twins request for a second game. After the pasta was eaten, the twins headed off to the lounge to watch a DVD cartoon while Ernie and I finished off the wine. "That was nice of you - losing on purpose to the twins - but don't you think you made it just a bit too obvious?" I suggested. "On purpose!" Ernie replied, "Not at all. It would be intellectually dishonest to do that". "Well then," I ventured, "I guess it was your first time playing. You do realize that a good player should be able to guess anything but the sneakiest secret code in no more than seven or eight turns?". Ernie gave me the look, and explained that in his opinion the game was 'trivial'. "If you really want to know" he continued, "it was my synasthesia acting up again - some of the combinations of colours smelled like rotting fish, sounded like fingernails on blackboards, and tasted like ear-wax. That's why I had trouble concentrating. If the game had consisted of numbers instead of colours I could have cracked any code in far less than eight turns". To say the least I had my doubts. "Then, how about we play a game with base-6 arithmetic instead of colours - and see how you fare against a real Master?" I suggested. I then prepared a set of paper tabs (suitably numbered) and glued them to the playing pieces so Ernie couldn't use his synasthesia as an excuse.

enter image description here

After a few games I thought I was going to have to eat my words. In our first ten games, with me setting the code, Ernie never needed more than 5 guesses to reveal the code. "Beginners luck!" I muttered under my breath. "Nothing to do with luck" Ernie replied. "I just used a simple algorithm that is nearly optimal against a random opponent". "Algorithm?" I thought, "How could a simple algorithm beat an experienced player like me in a game of skill and cunning like this?". I spent some time thinking up the most Machiavellian secret code possible. It was so convoluted that it would surely take Ernie a good eight or nine turns to guess. "Of course," continued Ernie, as I placed the secret code pegs in position, "against a non-random clue-setter like you I'm sure I can adapt the algorithm and win even faster. I notice that in your attempt to choose 'sneaky' numbers, you always end up choosing a prime - so I will assume that is the case in this game". I realized that my next code was prime, and my ears burnt in embarrassment. "Well, there's another way to be sneaky" I thought in desperation - I would change the rules to see if I could last more than five moves.

The game went like this:

Ernie said "I will choose the smallest possible prime", and played his guess.

I said (truthfully) "The sum of hits and misses is an odd number." (lets see how he dealt with that!).

Ernie said "Tricky, but no matter. I will choose the smallest possible prime consistent with the results so far", and played his guess.

I said (truthfully) "The sum of hits and misses is an odd number."

Ernie said "I will choose the smallest possible prime consistent with the results so far", and played his guess.

I said (truthfully) "The sum of hits and misses is an odd number."

Ernie said "I will choose the smallest possible prime consistent with the results so far", and played his guess.

I said (truthfully) "The sum of hits and misses is an odd number."

Ernie said "I will choose the smallest possible prime consistent with the results so far", and played his guess.

I said (truthfully) "Four hits - you win".

Ernie said "What a nice coincidence. You chose my favorite base-6 prime for your code".

At that point the kids came back and we switched to Snap (at which, thankfully, I was far better than Ernie) until it was time for them to leave. As Ernie was heading out the door, he turned back and told me that someone listening in on our conversation (from the point at which we started the last game), should have been able to guess his favorite base-6 prime number. Do you think he is right?

  • $\begingroup$ Did you purposely spell "synesthesia"/"synaesthesia" wrongly? $\endgroup$
    – justhalf
    Mar 21, 2017 at 7:33
  • $\begingroup$ Nope - I blame it on personal incompetence (although Ernie might claim that the 'correct' spelling smells awful). $\endgroup$
    – Penguino
    Mar 22, 2017 at 0:07
  • $\begingroup$ Has a correct answer been given? If so, please don't forget to $\color{green}{\checkmark \small\text{Accept}}$ it :) $\endgroup$
    – Rubio
    Apr 1, 2017 at 15:23

1 Answer 1


My guess:


First attempt is obviously:

0002, the smallest prime

Second attempt is:

0003, the next smallest prime, with the assumption of three hits (0)

Third attempt is:

0005, the next smallest prime, still with the assumption of three hits (0)

Now that the assumption of three hits fails, and that three misses is not a possibility, Ernie assumes that there was only one hit until now. His fourth attempt is then:

0111, the next prime (43 in base 10) that contains one 0 and none of 2, 3 and 5.

Three misses is not a possibility, therefore Ernie bets on three hits and choose:

0141, the next prime (61 in base 10) that contains one 0, two 1s in the last three positions, and none of 2, 3 and 5.

  • 1
    $\begingroup$ ................ $\endgroup$
    – Penguino
    Mar 22, 2017 at 0:10
  • $\begingroup$ @Penguino I don't get the meaning of this. But I'm not used to PSE and its customs, though. It's clear my answer is wrong but am I supposed to understand something else from those dots? $\endgroup$
    – xhienne
    Mar 24, 2017 at 0:06
  • $\begingroup$ Sorry for the confusion. I was in the midst of commenting when I had a sudden distraction (cat walking on keyboard type of thing). I believe your answer is correct. $\endgroup$
    – Penguino
    Mar 25, 2017 at 20:44
  • $\begingroup$ What do you mean by "believe". Aren't you Ernie's father? Don't you have the solution to the puzzle? Or is ti your cat that posted this riddle? :-) $\endgroup$
    – xhienne
    Mar 27, 2017 at 9:36
  • $\begingroup$ I don't know where you got the idea that I was Ernie's father - I can confirm I am not. And I can only assume the puzzle had a solution because he said it did (and I have always found him to be an honest man) - so thank you for finding the solution. Finally - it was a "cat walking on keyboard type of thing" - not actually a cat. Really a totally different animal, but for personal reasons I don't want to delve more deeply into that issue. $\endgroup$
    – Penguino
    Mar 27, 2017 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.