All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Two Logicians, Four Numbers (Posted on 2006-01-03)
Four different integers from 1 to 10 are chosen. Sam is given the sum and Pat is given the product. Sam and Pat take turns stating how many of the four numbers they can deduce:

Sam: I don't know any
Pat: I know one
Sam: I now know two
Pat: I now know all four

What could the four numbers be?

Tip: A spreadsheet is very useful in solving this problem.

 See The Solution Submitted by Brian Smith Rating: 4.0000 (7 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Don't know how to do this with a spreadsheet, but... | Comment 4 of 14 |

I'm more familiar with the Basic programming language:

DEFDBL A-Z

OPEN "2log4num.txt" FOR OUTPUT AS #2

CLS
DIM dig(210, 10)

DIM v(10)

DIM sum(210)
DIM prod(210)

DIM valid(210)

FOR a = 1 TO 7
FOR b = a + 1 TO 10
FOR c = b + 1 TO 10
FOR d = c + 1 TO 10
subs = subs + 1
dig(subs, a) = 1
dig(subs, b) = 1
dig(subs, c) = 1
dig(subs, d) = 1
sum(subs) = a + b + c + d
prod(subs) = a * b * c * d
valid(subs) = 1
NEXT
NEXT
NEXT
NEXT

FOR s = 1 TO 210
IF valid(s) THEN
t = sum(s)
FOR vs = 1 TO 10
v(vs) = 0
NEXT
sCount = 0
FOR s1 = 1 TO 210
IF sum(s1) = t AND valid(s1) = 1 THEN
sCount = sCount + 1
FOR vs = 1 TO 10
IF dig(s1, vs) THEN
v(vs) = v(vs) + 1
END IF
NEXT
END IF
NEXT
remove = 0
FOR vs = 1 TO 10
IF v(vs) = sCount THEN remove = 1: uniq = vs
NEXT
IF remove THEN
FOR s1 = 1 TO 210
IF sum(s1) = t THEN
IF valid(s1) THEN
remCt = remCt + 1
valid(s1) = 0
PRINT #2, "1 removing"; t;
GOSUB showEm
PRINT #2, uniq
END IF
END IF
NEXT
END IF
END IF
NEXT

PRINT #2, remCt

FOR s = 1 TO 210
IF valid(s) THEN
t = prod(s)
FOR vs = 1 TO 10
v(vs) = 0
NEXT
sCount = 0
FOR s1 = 1 TO 210
IF prod(s1) = t AND valid(s1) = 1 THEN
sCount = sCount + 1
FOR vs = 1 TO 10
IF dig(s1, vs) THEN
v(vs) = v(vs) + 1
END IF
NEXT
END IF
NEXT
remove = 0
FOR vs = 1 TO 10
IF v(vs) = sCount THEN remove = remove + 1
NEXT
IF remove <> 1 THEN
FOR s1 = 1 TO 210
IF prod(s1) = t THEN
IF valid(s1) THEN
remCt = remCt + 1
valid(s1) = 0
PRINT #2, "2 removing"; t;
GOSUB showEm
PRINT #2,
END IF
END IF
NEXT
END IF
END IF
NEXT

PRINT #2, remCt

FOR s = 1 TO 210
IF valid(s) THEN
t = sum(s)
FOR vs = 1 TO 10
v(vs) = 0
NEXT
sCount = 0
FOR s1 = 1 TO 210
IF sum(s1) = t AND valid(s1) = 1 THEN
sCount = sCount + 1
FOR vs = 1 TO 10
IF dig(s1, vs) THEN
v(vs) = v(vs) + 1
END IF
NEXT
END IF
NEXT
remove = 0
FOR vs = 1 TO 10
IF v(vs) = sCount THEN remove = remove + 1
NEXT
IF remove <> 2 THEN
FOR s1 = 1 TO 210
IF sum(s1) = t THEN
IF valid(s1) THEN
remCt = remCt + 1
valid(s1) = 0
PRINT #2, "3 removing"; t;
GOSUB showEm
PRINT #2,
END IF
END IF
NEXT
END IF
END IF
NEXT

PRINT #2, remCt

FOR s = 1 TO 210
IF valid(s) THEN
t = prod(s)
FOR vs = 1 TO 10
v(vs) = 0
NEXT
sCount = 0
FOR s1 = 1 TO 210
IF prod(s1) = t AND valid(s1) = 1 THEN
sCount = sCount + 1
FOR vs = 1 TO 10
IF dig(s1, vs) THEN
v(vs) = v(vs) + 1
END IF
NEXT
END IF
NEXT
remove = 0
FOR vs = 1 TO 10
IF v(vs) = sCount THEN remove = remove + 1
NEXT
IF remove <> 4 THEN
FOR s1 = 1 TO 210
IF prod(s1) = t THEN
IF valid(s1) THEN
remCt = remCt + 1
valid(s1) = 0
PRINT #2, "4 removing"; t;
GOSUB showEm
PRINT #2,
END IF
END IF
NEXT
END IF
END IF
NEXT

PRINT #2, remCt

FOR s1 = 1 TO 210
IF valid(s1) THEN
GOSUB showEm
PRINT #2, sum(s1); prod(s1)
END IF
NEXT

END

showEm:
FOR ii = 1 TO 10
IF dig(s1, ii) THEN PRINT #2, ii;
NEXT
RETURN

The results, with added manual annotations is:

For question statement 1, remove those for which Sam could have identified at least one number. After "removing" is shown the sum, the four numbers, and (one of the) number(s) that could be identified.

1 removing 10  1  2  3  4  4
1 removing 11  1  2  3  5  5
1 removing 12  1  2  3  6  2
1 removing 12  1  2  4  5  2
1 removing 13  1  2  3  7  1
1 removing 13  1  2  4  6  1
1 removing 13  1  3  4  5  1
1 removing 31  4  8  9  10  10
1 removing 31  5  7  9  10  10
1 removing 31  6  7  8  10  10
1 removing 32  5  8  9  10  10
1 removing 32  6  7  9  10  10
1 removing 33  6  8  9  10  10
1 removing 34  7  8  9  10  10
14 have been removed so far, out of the 210 combinations of 10 taken 4 at a time.

Then, per statement 2, if a given product would identify no number or would identify more than one number, the remaining sets with that product are eliminated. For example, a product of 48 would identify all the numbers; a product of 60 would identify both 1 and 2 as present; and a product of 180 would produce no number identification.

2 removing 48  1  2  3  8
2 removing 54  1  2  3  9
2 removing 60  1  2  3  10
2 removing 60  1  2  5  6
2 removing 56  1  2  4  7
2 removing 64  1  2  4  8
2 removing 72  1  2  4  9
2 removing 72  1  3  4  6
2 removing 80  1  2  4  10
2 removing 80  1  2  5  8
2 removing 70  1  2  5  7
2 removing 90  1  2  5  9
2 removing 90  1  3  5  6
2 removing 100  1  2  5  10
2 removing 84  1  2  6  7
2 removing 84  1  3  4  7
2 removing 96  1  2  6  8
2 removing 96  1  3  4  8
2 removing 108  1  2  6  9
2 removing 108  1  3  4  9
2 removing 120  1  2  6  10
2 removing 120  1  3  4  10
2 removing 120  1  3  5  8
2 removing 120  1  4  5  6
2 removing 120  2  3  4  5
2 removing 112  1  2  7  8
2 removing 126  1  2  7  9
2 removing 126  1  3  6  7
2 removing 140  1  2  7  10
2 removing 140  1  4  5  7
2 removing 144  1  2  8  9
2 removing 144  1  3  6  8
2 removing 144  2  3  4  6
2 removing 160  1  2  8  10
2 removing 160  1  4  5  8
2 removing 180  1  2  9  10
2 removing 180  1  3  6  10
2 removing 180  1  4  5  9
2 removing 180  2  3  5  6
2 removing 105  1  3  5  7
2 removing 135  1  3  5  9
2 removing 150  1  3  5  10
2 removing 162  1  3  6  9
2 removing 189  1  3  7  9
2 removing 240  1  3  8  10
2 removing 240  1  4  6  10
2 removing 240  1  5  6  8
2 removing 240  2  3  4  10
2 removing 240  2  3  5  8
2 removing 240  2  4  5  6
2 removing 200  1  4  5  10
2 removing 192  1  4  6  8
2 removing 192  2  3  4  8
2 removing 224  1  4  7  8
2 removing 320  1  4  8  10
2 removing 320  2  4  5  8
2 removing 360  1  4  9  10
2 removing 360  1  5  8  9
2 removing 360  2  3  6  10
2 removing 360  2  4  5  9
2 removing 360  3  4  5  6
2 removing 300  1  5  6  10
2 removing 300  2  3  5  10
2 removing 315  1  5  7  9
2 removing 350  1  5  7  10
2 removing 400  1  5  8  10
2 removing 400  2  4  5  10
2 removing 450  1  5  9  10
2 removing 378  1  6  7  9
2 removing 378  2  3  7  9
2 removing 480  1  6  8  10
2 removing 480  2  3  8  10
2 removing 480  2  4  6  10
2 removing 480  2  5  6  8
2 removing 480  3  4  5  8
2 removing 720  1  8  9  10
2 removing 720  2  4  9  10
2 removing 720  2  5  8  9
2 removing 720  3  4  6  10
2 removing 720  3  5  6  8
2 removing 324  2  3  6  9
2 removing 384  2  4  6  8
2 removing 448  2  4  7  8
2 removing 576  2  4  8  9
2 removing 576  3  4  6  8
2 removing 640  2  4  8  10
2 removing 600  2  5  6  10
2 removing 600  3  4  5  10
2 removing 700  2  5  7  10
2 removing 800  2  5  8  10
2 removing 900  2  5  9  10
2 removing 900  3  5  6  10
2 removing 672  2  6  7  8
2 removing 672  3  4  7  8
2 removing 756  2  6  7  9
2 removing 756  3  4  7  9
2 removing 864  2  6  8  9
2 removing 864  3  4  8  9
2 removing 1008  2  7  8  9
2 removing 1008  3  6  7  8
2 removing 1120  2  7  8  10
2 removing 1120  4  5  7  8
2 removing 648  3  4  6  9
2 removing 810  3  5  6  9
2 removing 945  3  5  7  9
2 removing 1050  3  5  7  10
2 removing 1200  3  5  8  10
2 removing 1200  4  5  6  10
2 removing 1350  3  5  9  10
2 removing 1134  3  6  7  9
2 removing 1296  3  6  8  9
2 removing 1620  3  6  9  10
2 removing 1512  3  7  8  9
2 removing 1512  4  6  7  9
2 removing 1890  3  7  9  10
2 removing 1890  5  6  7  9
2 removing 1400  4  5  7  10
2 removing 1600  4  5  8  10
2 removing 1800  4  5  9  10
2 removing 1344  4  6  7  8
2 removing 1728  4  6  8  9
2 removing 1920  4  6  8  10
2 removing 2016  4  7  8  9
2 removing 2240  4  7  8  10
2 removing 2520  4  7  9  10
2 removing 2520  5  7  8  9
2 removing 2100  5  6  7  10
2 removing 2400  5  6  8  10
2 removing 2700  5  6  9  10
2 removing 2800  5  7  8  10
2 removing 3024  6  7  8  9
145 combinations have been eliminated so far (including the original 14) out of the 210.

Then any set whose total does not identify exactly two out of the remaining sets is eliminated:

3 removing 19  1  3  7  8
3 removing 19  1  5  6  7
3 removing 19  2  3  5  9
3 removing 19  2  3  6  8
3 removing 19  2  4  6  7
3 removing 19  3  4  5  7
3 removing 21  1  3  7  10
3 removing 21  1  3  8  9
3 removing 21  1  4  7  9
3 removing 21  1  5  6  9
3 removing 21  1  5  7  8
3 removing 21  2  4  6  9
3 removing 21  3  4  5  9
3 removing 21  3  5  6  7
3 removing 23  1  3  9  10
3 removing 23  2  4  7  10
3 removing 23  2  5  7  9
3 removing 23  3  5  7  8
3 removing 23  4  5  6  8
3 removing 18  1  4  6  7
3 removing 18  2  3  4  9
3 removing 18  2  3  6  7
3 removing 18  2  4  5  7
3 removing 20  1  4  6  9
3 removing 20  2  3  7  8
3 removing 20  2  5  6  7
3 removing 20  3  4  6  7
3 removing 22  1  4  7  10
3 removing 22  1  4  8  9
3 removing 22  1  6  7  8
3 removing 22  2  3  7  10
3 removing 22  2  3  8  9
3 removing 22  2  4  7  9
3 removing 22  2  5  6  9
3 removing 22  2  5  7  8
3 removing 22  4  5  6  7
3 removing 24  1  6  7  10
3 removing 24  1  6  8  9
3 removing 24  2  3  9  10
3 removing 24  3  4  7  10
3 removing 24  4  5  6  9
3 removing 26  1  6  9  10
3 removing 26  1  7  8  10
3 removing 26  2  6  8  10
3 removing 26  3  4  9  10
3 removing 26  3  6  7  10
3 removing 26  4  5  8  9
3 removing 26  5  6  7  8
3 removing 25  1  7  8  9
3 removing 25  2  6  7  10
3 removing 25  3  4  8  10
3 removing 25  3  5  8  9
3 removing 25  4  5  7  9
3 removing 27  1  7  9  10
3 removing 27  2  6  9  10
3 removing 27  3  6  8  10
3 removing 27  4  6  7  10
3 removing 16  2  3  4  7
3 removing 17  2  3  5  7
3 removing 28  2  7  9  10
3 removing 28  3  7  8  10
3 removing 28  5  6  8  9
3 removing 30  3  8  9  10
208 have been eliminated so far.

Then, from  Pat's last statement, we don't actually gain any information. Still only
208 out of 210 have been eliminated.

What remains are these two (showing the four numbers, their sum and their product).

2  8  9  10  29  1440
4  6  9  10  29  2160

 Posted by Charlie on 2006-01-03 20:59:28

 Search: Search body:
Forums (0)