[Community Puzzle] Guessing digits

https://www.codingame.com/training/medium/guessing-digits

Send your feedback or ask for help here!

Created by @Jamproject,validated by @JBM,@crashtestdummy and @Jakque.
If you have any issues, feel free to ping them.

I don’t get why it got so many downvotes, it’s a nice puzzle.

1 Like

Continuing the discussion from [Community Puzzle] Guessing digits:

I don’t understand this task!
What mean " asks Burt if he knows a and b" - Burt try random or try find one by one…
i use to for loop but it seems to be wrong idea.
I don’t understand who find this a and b

The name is slightly misleading as guessing isn’t allowed. They either know the exact digits or have to say they don’t know. As they both start with different information saying that they don’t know tells the other person something so at some point there is only one pair of digits or it’s impossible.

2 Likes

Example: numbers are 2 and 5
Turn 1
Burt is given 7, there are multiple combinations that give a sum of 7 so he doesn’t know which one.
Sarah is given 10, the only combination is 2*5 so she can find out.

Now, let’s consider another example where Burt is given 7. If Sarah doesn’t find the digits on turn 1, then Burt knows for sure that the combination is not (2, 5).

By filling a big chart with the history of what can be discovered at each turn, it kills possibilities turn after turn and some of them become findable at some point.

3 Likes

Indeed, it’s a smart one. But it needs more explainations. Without yours, I would have skip the puzzle.

Hi,
I am having a hard time solving this puzzle, and I think I need a little bit more information. Here is what I understand after reading the problem description:

Maggie picks two digits a and b with 1 ≤ a ≤ 9, 1 ≤ b ≤ 9, and ab.

She writes their sum on a blue piece of paper, folds it, and says “Here is the sum of the two digits I chose” while handing it to Burt.

She then writes their product on a red piece of paper, folds it, and says “Here is the product of the two digits I chose” while handing it to Sarah.

Burt and Sarah do not share the contents of their respective pieces of paper.

The game is played in rounds.

In each round, Burt plays first by announcing his guess for (a, b), in this case (n, m).

  • If Burt guesses right, the game ends with "(n,m) BURT round number"
  • If Burt guesses wrong, then Sarah gets to announce her guess (p,q).
    If she guessed correctly, the game ends with "(p,q) SARAH round number".
    Otherwise, we proceed to the next round.

If any of the players is out of guesses when his/her turn comes, the game ends with “IMPOSSIBLE”.

Did I understand correctly?

1 Like

Not exactly, there are no “guesses”, either the player knows for sure what (a, b) is and tells it, or the players doesn’t say anything and we move to the next player.

So a typical game would look more like this:

B: “I don’t know”
S: “I don’t know”
B: “I don’t know”
S: “I don’t know”
B: “I don’t know”
S: “I know, it’s a = … and b = …”

Which might be a bit disturbing but that’s how it is ^^

1 Like

Ok, let me try again (-_-)>.

So before the game starts, let say Ώ is the set of possible pairs (a,b) such that 1 ≤ a ≤ 9, 1 ≤ b ≤ 9, and ab.
Maggie chooses an element (a, b) of Ώ and gives respectively the values s = a + b and p = a * b to Burt and Sarah.

Knowing s, Burt can narrow down Ώ to a subset S of possible solutions.
Sarah can also determine a subset P of Ώ from the value of p.

The game is played in rounds. In each round, Burt plays first.

If Burt is certain of knowing the answer |P| = 1 (i.e. P contains only one element) he announces it and the game ends, otherwise he passes his turn.
Sarah can then announce her answer if |S| = 1 or passes.
If both pass their turn, we proceed to the next round.

The fact that Burt/Sarah passes his/her turn should help his/her opponent further narrow down his/her set of possible solutions.

Am I getting warmer?

1 Like

Yes it’s exactly that.
It’s all about “if it was a = …, b = … he would have figured out by this turn and he didn’t, so it’s not that, let’s remove this one”.

1 Like

Gosh! I would have been really deep in the weeds, without your assistance.
Now that I have a better understanding of the basic premise of this puzzle, time for the hard part…solving it!
You saved me from a huge headache, thanks! (^_^)b

1 Like

Right, But the description doesn’t say how Sarah and Burt proceed to guess the numbers. (random or trying for the minor number to the greater, or from the greater combination to the minor one).
It’ s the worst puzzle description I ever seen.