The Polka Dot puzzle uses eleven cards numbered from 0 to 10. The back of all cards is the same, so they can not be distinguished from each other. Arrange the cards so that they form a stack. Then deal the top card up, next card to the bottom of the deck, card up, next on the bottom, card up, next on the bottom, and so on until all cards have been dealt.
In what order should you arrange the cards in the original deck, so that they are dealt in the order 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10? The following video demonstrates a successful deal.
This is a classic puzzle that is often used to learn problem solving skills to children. Solving the puzzle with real cards is an astonishingly good challenge for a wide range of kids. If using eleven cards is initially too hard, the kids can try using three, five or seven cards to start and slowly work their way up. There's an easy way to pepper successes in as they approach the larger challenge, which is one of the best ways to develop perseverance.
There is a plethora of different strategies that can be used to tackle the Polka Dot puzzle, but this is probably the most elegant method for solving it. Put as many dots in a line as there are cards. Place a zero on the first dot. Now, starting at the zero, place each next number at the second unused dot — when reaching the end of the line, start again at the beginning. Repeat this procedure until numbers have been placed on all dots. The following scheme demonstrates how this procedure works for eleven cards that have to be dealt in the order 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
The above procedure not only works with numbers, but with any sequence of items, irrespective of the length of the sequence. Your task:
Write a function deal that takes a sequence (list, tuple or str) of items. The function must return a new list (list) containing the items from the given sequence in the order they are dealt when applying the way of dealing used in the Polka Dot puzzle.
Write a function polka that takes a sequence (list, tuple or str) of items. The given sequence indicates the order in which we want to deal the items when applying the way of dealing used in the Polka Dot puzzle. The function must return a new list (list) containing the items from the given sequence in the order they have to be arranged in the initial stack, such that they will be dealt in the given order.
>>> deal((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
[0, 2, 4, 6, 8, 10, 3, 7, 1, 9, 5]
>>> deal([0, 8, 1, 6, 2, 10, 3, 7, 4, 9, 5])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> deal('ABCDEFGHIJKLMOP')
['A', 'C', 'E', 'G', 'I', 'K', 'M', 'P', 'D', 'H', 'L', 'B', 'J', 'F', 'O']
>>> deal('ALBICODJEMFKGPH')
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'O', 'P']
>>> polka((0, 2, 4, 6, 8, 10, 3, 7, 1, 9, 5))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> polka([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
[0, 8, 1, 6, 2, 10, 3, 7, 4, 9, 5]
>>> polka('ACEGIKMPDHLBJFO')
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'O', 'P']
>>> polka('ABCDEFGHIJKLMOP')
['A', 'L', 'B', 'I', 'C', 'O', 'D', 'J', 'E', 'M', 'F', 'K', 'G', 'P', 'H']
Math for Love1 is a Seattle-based team (United States) that is out to transform math education through puzzles, games and teacher workshops. In 2014 they launched a successful fund raising campaign on Kickstarter2 to enable them to release Tiny Polka Dot, a collection of mathematical games for 3-8 year-olds packed into one colorful card deck. In his presentation on Ted Talks, Daniel Finkel of Math for Love explains the goals of his organization:
The oldest version of the Polka Dot puzzle is found as The Nun's Puzzle3 in the 1907 book The Canterbury Puzzles4 by Henry Dudeney. Dudeney calls the puzzle easy to solve if you use actual cards, and suggests solving it without them.
Burns M (1982). Math for Smarty Pants. Little Brown Books for Young Readers. 5
Dudeney HE (1907). The Canterbury Puzzles and Other Curious Problems. Thomas Nelson and Sons, LTD., London, Edinburgh and New York. 6
Stenmark JK, Thompson V, Cossey R, Hill M (1986). Family Math. Lawrence Hall of Science. 7