Brain-Teaser 606: Pints all round
From The Sunday Times, 18th February 1973 [link]
“Little puzzle here”, says Bell at the pub, squeezing himself in. “Move up. Now, we are seven sat round the table. I am No. 1, naturally, and you are 2, 3, up to 7 and back to No. 1 clockwise”.
“These cards numbered 1 to 7. I shuffle and deal. If you have your own number, say ‘Hit!’. Only one hit? Good! Pass the cards to your left one place. Double hit? Bad”.
“The trick is to find out how the cards should be dealt for a single hit each time the cards are passed. I’ll make it easy. I always get the first hit and then numbers 2 and 6 get their hits as early as possible after that. Everything’s clockwise, numbering, dealing and passing”.
“Usual prize one pint”.
“Difficult? It’s a pushover. If you’re thirsty I’ll give you a hint. Let’s have a look at your cards. Anybody can see number 6 is going to come up last. Swap them round a bit. Hold on! Now you’ve got 5 then 2 then 7, so when 5 gets a hit so does 7. You’ve got to avoid that kind of thing”.
In what order should the cards be dealt, beginning with No. 1 and proceeding clockwise?
This puzzle is included in the book Sunday Times Brain Teasers (1974).
[teaser606]
Jim Randell 5:22 pm on 6 August 2023 Permalink |
This Python program considers all possible arrangements of cards, and runs the process looking for a single hit on each turn. And it reports those with 7 turns that each give a single hits, and the first hit is 1. And I look for cases where the index sum of cards 2 and 6 in minimised.
It runs in 63ms. (Internal runtime is 11.2ms).
Run: [ @replit ]
from enigma import (Accumulator, irange, rotate, subsets, singleton, printf) # find sequences of single hits def hits(ss): hs = list() while True: # we want a single hit on each turn h = singleton(x for (x, y) in enumerate(ss, start=1) if x == y) if h is None: break hs.append(h) if len(hs) == len(ss): break # pass the cards to the left ss = rotate(ss, -1) # return the order of the hits return hs r = Accumulator(fn=min, collect=1) # consider possible arrangements of the cards for ss in subsets(irange(1, 7), size=len, select='P'): hs = hits(ss) # single hit each time if not (len(hs) == 7): continue # the first hit is 1 if not (hs[0] == 1): continue # accumulate values by positions for 2 and 6 r.accumulate_data(hs.index(2) + hs.index(6), ss) # output solution for ss in r.data: printf("{ss}")Solution: The cards should be dealt in the order: 1, 5, 7, 3, 6, 4, 2.
LikeLike