Flipping Cards

Source

I got this problem from Rustan Leino, who had heard several versions of it. He first heard it from Bertrand Meyer, who got the problem from Yuri Gurevich.

I solved it and wrote up my solution.

Problem    

You're given a regular deck of 52 playing cards. In the pile you're given, 13 cards are face-up and the rest are face-down. You are to separate the given cards into two piles, such that the number of face-up cards in each pile is the same. In separating the cards, you're allowed to flip cards over. The catch: you have to do this in a dark room where you cannot determine whether a card is face-up or face-down.

Solution     Reveal