My friend just told me this riddle and I cannot for the life of me figure out the answer. But he assures me there is one.

There's a room with 64 cups, one of them is water and the rest are poisoned. In front of each cup is a light when you go into the room, you will know which cup is safe, and you will be able to turn one light on or off to let your friend know which cup to drink. However the lights will be randomly on and off, and you won't know the configuration until you're in the room.

You know the organization of the cups (for example we can just say it's a straight line of them), but you aren't allowed to move the cups, or mark them in any way. And my friend assures me it's not 'leave the light on until the cup is warmer'. Basically, it's a light pattern, not some sneaky unexpected answer.

Obviously you need to establish a code with your friend, but how do you establish a way to tell him which cup in a line of 64 while only being able to change one light?

Sorry if this is the wrong place to post this, if so please let me know where I should post it!


Here's how you do it:

Take those 64 cups and lights. Number them 0..63. Take the exclusive-or of the numbers of all the lights that are on. We will make this equal the number of the safe cup. Can we always do this? Why, yes: if before we come along the XOR is 'a' and the safe cup is 'b', we have only to switch light 'a' XOR 'b'.

I have definitely seen almost this exact puzzle before, but I don't think it was here and annoyingly I can't remember where it was. A bit of web searching quickly turns up e.g. this discussion of the puzzle, with no indication of where it comes from. I'm sure that isn't where I saw it, so apparently other instances exist. Can anyone figure out the original source?


I don't know if this counts as sneaky, but:

Whichever one he sees you change is the water

Otherwise, you'd have to do the reveal over and over (resetting the lights and picking a new one to switch to establish some pattern). Your question doesn't specify whether we can do this repeatedly. It also doesn't specify whether the friend is in the room while you do the switching.


Not the answer you're looking for? Browse other questions tagged or ask your own question.