You are standing in a pitch-dark room. A friend walks up and hands you a normal deck of 52 cards. He tells you that 13 of the 52 cards are face-up, the rest are face-down. These face-up cards are distributed randomly throughout the deck.

Your task is to split up the deck into two piles, using all the cards, such that each pile has the same number of face-up cards. The room is pitch-dark, so you can’t see the deck as you do this.

How can you accomplish this seemingly impossible task?

Take the first 13 cards off the top of the deck and flip them over. This is the first pile. The second pile is just the remaining 39 cards as they started.

The logic can be a bit difficult to digest, so let’s look at an example. Let’s assume that from the first 13 cards, 5 of them are face-up. So from the remaining 39 cards, 8 cards will be face-up. When we flip the cards from the first pile of 13 cards, 8 of them will become face-up and 5 will be face-down.