# Can you open the door or die?

You wake up and find yourself in a very strange room with a single door. You find a note on the ground surrounded by lots of cards:

There are 66 green and 66 blue door cards on the ground. If you put one blue and one green card into the slots next to the door, the door will open. If you insert two cards of the same color, you will lose a life! I won't tell you how many lives you have, but you will die if you lose all of them!

For most people, this could be completed easily. Unfortunately, you cannot distinguish the color of the cards because you are fully colorblind! Whoever put you there probably knows this. They undoubtedly gave you just enough lives for you to be certain you can get out - if you play their game optimally.

How many tries do you need to guarantee you open the door?

• Can I get the cards back after an attempt? – cinico Jun 10 at 19:59
• @cinico of course – Oray Jun 10 at 20:09

I believe I can open it in

66

The reasoning behind it is:

The general strategy I'll be using is just brute-forcing a single card against all others. Pick a card, this'll be the "master" card you'll always use. Then you simply test the master card with another card up to 66 times. If it doesn't work, than you toss out the non-master card, and repeat.
As there are an equal number of green and blue cards (66), we can solve it the same regardless of the first card you chose.
So say your first card is green, then the worst case is that you fail your first 65 tries by getting 65 greens in a row. Then on the 66th try you're guaranteed to have a matching blue card since there are no green cards remaining besides the one in your hand.
The argument applies in exactly the same way if you chose a blue card first, just with blue cards instead.

• Ooo, I like it! I'll have to think more on it (Sorry, my discrete math's a bit rough around the edges) – Jay Jun 10 at 19:00
• This seems far too simple to be the answer, but I can't think of a better one. – scatter Jun 10 at 19:29
• I think you can do it in less if you do it in pairs. I'll try to organize this idea and write up an answer – João Bravo Jun 10 at 20:04

This is like a reverse puzzle to the well-known

"How often do you have to break a chocolate apart to end up with 24 pieces?" - The answer is 23 because every act of breaking - no matter how - increases the number of pieces by exactly one

Here in reverse:

Any failed attempt with two cards in effect only tells you that these two cards have the same colour. As they are henceforth equivalent, you can as well dispose one of them - or to stay in the spirit of the chocolate puzzle, glue them together to a larger monochromatic card cluster. The only move that guarantees that the door opens is when you would upon failure produce a card cluster of 67 or more cards (as a cluster of this size cannot be monochromatic). But producing a cluster of size 67 is easily possible in many different ways with 66 moves, but definitely not with less than 66 moves (cf. chocolate puzzle)

A remark as a thinking outside the box solution:

Most cases of colour blindness are red-green blindness and as far as I know can distinguish blue from green ;)

• As a colorblind person myself, I can confirm that yes, I can generally distinguish blue from green. That said, if the green is slightly blue-tinted or vice versa, the two colors would look a lot more similar to me than they would for a normal-sighted person. In general, for a colorblind person, all colors look a bit more like other colors than they should (with the exception of red and green, which look a lot more like each other than they should). So it's possible that the cards are shades of blue and green that would stump only colorblind people. – Gilad M Jun 10 at 21:27
• Unlike the accepted answer, this answer proves that their number is the minimum. – user3294068 Jun 11 at 16:51
• The logic here doesn't quite work. If you have two clusters of size 65, then inserting the two unclustered cards must produce a success, even though a failure would not result in a cluster of size 67 - one more attempt would be needed to produce a size-67 cluster. The condition upon which a move must succeed is not when its failure would produce a size-67 cluster, but when its failure would mean that there is no longer a set of clusters with a combined size of exactly 66 cards. – user2357112 Jun 12 at 8:25
• To patch the hole in the proof, we must prove that any sequence of 65 failures must still leave a set of clusters of combined size exactly 66. – user2357112 Jun 12 at 8:30
• (This last condition turns out to be equivalent to problem 8 in the Australian Mathematical Olympiad 2018) – boboquack Jul 15 at 5:49

I can do it in

34. I would try 33 times with pairs of cards that I haven't tried before. Either at least one pair will one green and one blue card, or all the 66 cards that have been tried are of the same color. For the 34th try, I would take one card from the 66 that I used and on from the 66 cards that I haven't used, making sure that at least one of my tries contains two cards of different colors.

• The 66 cards you tested don't necessarily need to be all the same colour. The first 17 pairs could be all blue and the next 16 all green, for example. – hexomino Jun 12 at 20:49

If I can get the cards back after an attempt

the minimum number of tries to open the door is 3. Pick 3 cards. Worst case scenario is: you pick green and blue for the first attempt; then you pick one of the first and test it against the third, which fails. Then, you know that the third card will match the card unpicked on the second attempt and you can open the door.

Otherwise,

It is not guaranteed that you can open the door, because there is a chance that you will always pick different colors for the 66 attempts.

• This is the right answer, but to a different question (the left and right sock problem). Read again, what condition opens the door. – Hagen von Eitzen Jun 10 at 20:12
• I'm must be slower than usual today, because I don't understand what I misunderstood from the conditions – cinico Jun 10 at 20:44
• You are thinking that equal colors will open the door. They must be different – João Bravo Jun 10 at 20:45
• What happens if you pick three same-colored cards? Then no combination of your three cards will open the door. – Somebody Jun 11 at 16:19