• 25

## Goal

Three very intelligent students – Maggie, Burt and Sarah – are taking a break playing a little game.
The game consists in guessing a couple of digits.
First, Maggie picks up two digits a and b from 1 to 9 included (a and b can be equal).
She writes the sum of those on a blue piece of paper and gives it to Burt.
She writes the product on a red piece of paper and gives it to Sarah.

Then, she asks alternatively Burt then Sarah if they know the two numbers until one of them, if it is possible, finds them.
You must output the two digits a and b picked by Maggie, the name of the first person guessing the digits followed by the number of rounds which are necessary (one round corresponds to ask Burt and Sarah). If the digits cannot be guessed, output “IMPOSSIBLE”.
Input
Line 1: One Integer x corresponding to the number Burt received
Line 2: One Integer y corresponding to the number Sarah received
Output
Line 1: The two digits a and b in ascending order in brackets, the name of the first person to guess (BURT or SARAH) and the number of rounds, all separated by a space. Ex: "(1,2) SARAH 1"
If the two digits cannot be guessed, output:IMPOSSIBLE.
Constraints
Example
Input
3
2
Output
(1,2) BURT 1

A higher resolution is required to access the IDE

Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants