Brainteaser 1770: Magic spell
From The Sunday Times, 18th August 1996 [link]
Marvo uses a prearranged pack of cards to perform the following trick. Holding the pack face downwards, one by one he would take a card from the top and place it on the bottom, calling out a letter each time so as to spell:
A, C, E, [the next card is an ace, which is placed on the table]
T, W, O, [next card is a 2]
T, H, R, E, E, [next card is a 3]
…
J, A, C, K, [next card is a Jack]
Q, U, E, E, N, [next card is a Queen]
K, I, N, G, [next card is a King]
A, C, E, [next card is an ace]
T, W, O, [next card is a 2]
…Once he had spelt out the name of the card he would remove the next card from the pack, turn it over and place it face up on the table. Of course it was always the card which he had just spelt out.
In this way he worked through the clubs, then the hearts, then the diamonds and finally the spades, finishing with just the King of spades in his hand.
One day his disgruntled assistant sabotaged his act by secretly cutting the pack. However the first card which Marvo turned over was still an ace, and the the second card was still a two.
What was the next card Marvo turned over?
This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.
[teaser1770]
Jim Randell 10:28 am on 8 December 2019 Permalink |
We can construct the initial configuration of the pack by starting with a pack of blank cards numbered in order from 1 to 52, and then performing the trick, but when we turn over one of the blank cards we write the appropriate value and suit on the card and continue until the end of the trick. We can then use the numbers to put the pack back into the desired order.
We can then look through the pack for an ace followed 4 cards later by a two, and then we are interested what card occurs 6 cards after that.
This Python program runs in 70ms.
Run: [ @repl.it ]
from enigma import irange, printf # words for each value word = { 'A': 'ACE', '2': 'TWO', '3': 'THREE', '4': 'FOUR', '5': 'FIVE', '6': 'SIX', '7': 'SEVEN', '8': 'EIGHT', '9': 'NINE', 'X': 'TEN', 'J': 'JACK', 'Q': 'QUEEN', 'K': 'KING', } # the positions in the pack pack = list(irange(0, 51)) # map position -> value + suit m = dict() # go through the suits for s in "CHDS": # and then the values in each suit for v in "A23456789XJQK": # apply the operation the appropriate number of times for x in word[v]: pack.append(pack.pop(0)) # reveal and discard the top card n = pack.pop(0) assert n not in m # record that card at this position m[n] = v + s # advance by counting value v advance = lambda k, v: (k + len(word[v]) + 1) % 52 # look for an ace... for (k1, v1) in m.items(): if v1[0] != 'A': continue # but not not the ace we are expecting if v1 == 'AC': continue # ... followed by a 2 ... k2 = advance(k1, '2') v2 = m[k2] if v2[0] != '2': continue # ... and what is the next card? k3 = advance(k2, '3') v3 = m[k3] printf("@{k1}: {v1} -> @{k2}: {v2} -> @{k3}: {v3}")Solution: The third card turned over is the three of diamonds.
After that the trick would go awry. The next card turned over is not a 4, it is 8♦.
The original layout of the pack is:
After the pack is cut 4♣ is at the top (as highlighted in the diagram), after counting out A, C, E we get A♠, and then T, W, O gets 2♥, and then T, H, R, E, E gets 3♦.
LikeLike