4 ms·
I had to see this myself: http://gist.github.com/592622 http://gist.github.com/592622 Ruby proved it right, but I still don't get it. :-(
by timmorgan 16y ago
I had to see this myself: http://gist.github.com/592622 http://gist.github.com/592622
Ruby proved it right, but I still don't get it. :-(
- zck 16y agoTo prove the solution works: Take ten chosen cards from the deck. Call this set of cards C. Number them c1 through c10. Similarly, number the face-up cards f1 through f10, such that if a face-up card was taken, it has the same number in both orderings. Note that, at the end of arranging the decks, if a card is face-down, it doesn't matter where it is. The only thing we care about is the locations of the face-up cards. So we can ignore all the cards that aren't in the C or F sets, as they're all face-down in the original deck. Now, for each card cx in the C deck, flip it over. There are two cases: either cx == fx (i.e., the card was originally face-up), or cx != fx. If cx == fx, you've flipped it face down, and it doesn't contribute to the count of face-up cards for either deck. If cx != fx, you've flipped it face-up, and fx is in the original deck. So we can increase the count of face-up cards in both decks by one. So, for each card we've chosen, either that card contributes nothing to the count of face-up cards in either deck, or it contributes one to the count of both decks.
- timmorgan 16y agoThank you. Telling me to ignore the face-down cards let me wrap my brain around this one.
- deleted 16y ago[deleted]
- deleted 16y ago[deleted]