3 ms·
Gist of this, since formatting got screwy: https://gist.github.com/josefdlange/04c9eb14a9ddbdfae8eb2e34b91d56df https://gist.github.com/josefdlange/04c9eb14a9dd
by josefdlange 10y ago
Gist of this, since formatting got screwy: https://gist.github.com/josefdlange/04c9eb14a9ddbdfae8eb2e34b91d56df https://gist.github.com/josefdlange/04c9eb14a9ddbdfae8eb2e34...
Seeing the others' answers I don't think matters in this solution.
The strategy -- given that it's allowable to discuss strategy before drawing cards -- is each person has a different modulo result (x) they have to compute the number they must add [to the sum of the other three], (m) in the following algebra. Solve for m to get the suit your should guess.
x = ([sum of others] + m) % 4
Suits:
0: Diamond
1: Heart
2: Club
3: Spade
Example:
[PLAYER]: (SUIT THEY HAVE), (CHOSEN MODULO RESULT)
A: (0) (0)
B: (1) (1)
C: (3) (2)
D: (3) (3)
For A's m: ((1 + 3 + 3) + m) % 4 == 0, therefore m = 1
For B's m: ((0 + 3 + 3) + m) % 4 == 1, therefore m = 3
For C's m: ((0 + 1 + 3) + m) % 4 == 2, therefore m = 2
For D's m: ((0 + 1 + 3) + m) % 4 == 3, therefore m = 3
D guesses correct.
There are many permutations of the drawn cards, but I think this one does solve it. All props to the person up this thread who initially answered the 4-player problem; I'm just explaining their methodology as I understood it.
- ulrikrasmussen 10y agoThanks! I misread the answer and took it for the solution to a different but related puzzle
- pliny 10y agoIf they have (A,B,C,D) = (0,1,0,1): A sees 1+0+1 -> guesses (2+0)%4 = 2 (wrong) B sees 0+0+1 -> guesses (1+1)%4 = 2 (wrong) C sees 1+0+1 -> guesses (2+2)%4 = 0 (wrong) C sees 0+1+0 -> guesses (1+3)%4 = 0 (wrong) EDIT: This is twice incorrect, as indicated below.
- im4w1l 10y ago1. You got your signs messed up. They should subtract the observation from the total. 2. C correctly guesses 0 in your example.
- nonsequitur 10y agoThere's no assignment to the „m“ variables that would make your algorithm work in the general case. im4w1l's strategy is just: Player i returns (i - [Sum of the other players' suits]) % 4 (With i ranging from 0 to 3)
- josefdlange 10y ago`m` is the result; this scratch here is meant to resemble algebra, not programming. You know, solve for `m`, etc.
- josefdlange 10y agoBut the subtraction is simpler. I didn't want to confuse anyone with moduloing a negative number.
- deleted 10y ago[deleted]
- javitury 10y agoTake a look at: https://gist.github.com/javiertury/bf71d37ff26643eca939c664264346ea https://gist.github.com/javiertury/bf71d37ff26643eca939c6642... I've tried my best to illustrate why this is the correct solution in the url above. Long story short: Call S to the sum of all the numbers on the hats of every player. The sum of all the numbers a player can see will be less than S but the difference with S will be less than "n - 1". Also the difference between the largest guess(for the sum of all the hats) and S won't be larger than "n - 1". There is now a problem, we want a set of guesses with a size no larger than "n" but in reality it can be as large as size "2(n - 1) + 1 = 2n - 1". Taking the set of possible rational guesses modulo "n" creates a collision, now some guesses will share the same remainder modulo n. However because no guess can be farther than "n - 1" with respect to S, the set of guesses modulo "n" won't create that collision for "S mod n". Any player that was told to make the remainder of the total sum mod n equal to "S mod n" will always have the correct answer. If you want to think visually imagine the modular clock for "n" which has "S mod n" as the reference point. Because no other point can't be farther apart than "n - 1" distance from S, only S can give the remainder "S mod n". If there are "n" players and we assign each one a different remainder "mod n", one of them will have the correct answer for sure.