# In the darkroom, you are handed a deck of cards.

This task was once popular at interviews in JP Morgan Chase. Surely, once in the darkroom, you will just take your smartphone and use the screen or a flashlight. However, this task had created before the era of smartphones and can be solved without observing the cards.

• With an imperious deck division, it is unlikely that there will be an equal number of cards face down in each pile (this can possible in case you are very lucky). Moreover, all the cards face up can appear in one pile.

• It is not mentioned in the task that both piles should be equal. The only specification is that there should be an equal number of cards face down.

• You can turn over the cards. Surely, there is no method that may advise you whether you turn over the cards face up or down.

The right solution is to count N cards, starting from the deck’s top, and turn them over. It will be one pile. The rest of the deck will be the second pile.

Let’s take a deeper look to understand the way it works. There can be any number of cards face-up in the N cards that you counted, from zero to N. Imagine that there were (before turning over) such f cards. By turning over the cards, you have reached that each card face up becomes face down and vice versa. Therefore, instead of f face-up cards, you come to the N-f face-up cards in this pile.

In the other pile, there are N cards face-up without those f cards that you counted. This is the same amount as in the first pile with the turned over cards.