Skip to content

Instantly share code, notes, and snippets.

@danott
Last active April 13, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danott/49b6ec20c28fa4312d5aab4b558f0861 to your computer and use it in GitHub Desktop.
Save danott/49b6ec20c28fa4312d5aab4b558f0861 to your computer and use it in GitHub Desktop.

Question

Two intelligent, honest students are sitting together at lunch one day when their math teacher hands them each a card. "Your cards each have an integer on them," the teacher tells them. "The product of the two numbers is either 12, 15 or 18. The first to correctly guess the number on the other's card wins."

The first student looks at her card and says, "I don't know what your number is."

The second student looks at her card and says, "I don't know what your number is, either."

The first student then says, "Now I know your number."

What number is on the loser's card?

Answer

The number on the loser's card is 6.

The possible combinations of integers is:

12 = 1 x 12
12 = 2 x 6
12 = 3 x 4
12 = 4 x 3
12 = 6 x 2
12 = 12 x 1
15 = 1 x 15
15 = 3 x 5
15 = 5 x 3
15 = 15 x 1
18 = 1 x 18
18 = 2 x 9
18 = 3 x 6
18 = 6 x 3
18 = 9 x 2
18 = 18 x 1

Anyone that has a 12, 15, 18, 4, 5, or 9 knows the other person's card, because they are uniq factors across 12, 15, and 18.

If the left operand is the first person, and the right operand is the second person, These combinations would answer in the following way:

Operands Left knows other number right knows other number
12 = 1 x 12 No Yes
12 = 2 x 6 No No
12 = 3 x 4 No Yes
12 = 4 x 3 Yes No
12 = 6 x 2 No No
12 = 12 x 1 Yes No
15 = 1 x 15 No Yes
15 = 3 x 5 No Yes
15 = 5 x 3 Yes No
15 = 15 x 1 Yes No
18 = 1 x 18 No Yes
18 = 2 x 9 No Yes
18 = 3 x 6 No No
18 = 6 x 3 No No
18 = 9 x 2 Yes Yes
18 = 18 x 1 Yes No

Taking only the "no, no" answers leaves us with:

18 = 3 X 6
18 = 6 X 3
12 = 2 X 6
12 = 6 X 2

What are the possible values in the second person's hand if the first person has a 3, 6, or 2?

6 x ?
6 x 2 = 12 means both have said "I don't know", with not enough information to know
6 x 3 = 18 means both have said "I don't know", with not enough information to know

2 X ?
2 x 9 = 18 means the second would have said "I know"
2 x 6 = 12 means the second would have said "I don't know", meaning it's not 9, so it must be six

3 x ?
3 x 4 = 12 means the second person would have said "I know"
3 x 5 = 15 means the second person would have said "I know"
3 x 6 = 18 means the second person would have said "I don't know", meaning it's not 4 or 5

So if the left person has a 2 or a 3, they're able to deduct that the right person has a 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment