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.

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

1 Like

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.

3 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 `a`

â‰¤ `b`

.

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 `a`

â‰¤ `b`

.

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.

1 Like

It is the problem of Freudenthal. It is a difficult problem.

The problem with this task is that this puzzle has some wrong assumptions and errors in my opinion e.g.

- Maggie shared 11 and 24 the outcome should be â€śImpossibleâ€ť where both can guess the right answer (3 & 8)
- If Sarah has les combination than Burt (or otherwise) she/he should win more often or quicker but when youâ€™re testing your solution it shows different outcome, e.g. for 7 and 6, Sara has only two options (2,3) and (1,6) but outcome is (1,6) SARAH 3. How is it possible??? She doesnâ€™t need three rounds to guess numbers. Also, assumption that she will take 1,6 instead of 2,3 is questionable because it depends how will you create your loops from 1 to 9 or from 9 to 1â€¦

This puzzle deals with recursive logics, itâ€™s not an easy concept.

Thereâ€™s nothing wrong about the statement, itâ€™s just that you didnâ€™t understand the concept.

Maybe try an easier one, or if you really want to solve it, the first task is to understand why you are wrong, and I can try to explain it for you but youâ€™ll learn more if you do the whole process yourself.

I write specifically for those who avoid tasks with a low rating:

I have now solved this puzzle.

This is an interesting challenge.

At 90% this is a logic problem, I had to think carefully about what was happening.

The programming of the solution itself is not difficult.

Straight up trash.

When the numbers are 1 and 9 the outpuit â€śshoulsâ€ť be impossible???$

How cna bart not guess it??

dogshit puzzle and awful explanationâ€¦ question yourself

You may criticise the puzzle, but please tone down your language.