Brain teaser 1006: Seafood dinner
From The Sunday Times, 8th November 1981 [link]
The exclusive Ichthyophage Club was invited to hold its annual dinner at a resort on the Costa Fortuna last summer. Several members accepted the invitation, and each was asked to bring one of the local seafood specialities as their contribution to the feast.
The fare consisted of:
• the local edible starfish, which has five legs,
• the squid, which has ten,
• and octopus.Each guest provided one such creature, and in fact more people provided octopus than provided starfish.
A chef was hired locally. He arranged the food so that each guest received a plateful consisting of the same number of legs — at least one leg from each species — but no guest’s plate was made up in the same way as any other guest’s plate. In other words, no guest had the same combination of legs on his plate as any other guest did.
When the food had been arranged in this way, the chef was grieved to find that all the legs had been used, leaving no edible fragments for him to take home to his family.
How many guests were there?
How many brought starfish, how many brought squid, and how many brought octopus?
This puzzle is included in the book The Sunday Times Book of Brainteasers (1994).
[teaser1006]
Jim Randell 9:29 am on 3 March 2026 Permalink |
Suppose there were n guests, and x of them brought a starfish, y of them brought a squid, z of them brought an octopus (each with their full complement of legs).
And they are each served a different arrangement of k legs, then:
This Python program considers increasing numbers of guests, and looks for viable decompositions that allow a different arrangement of legs to be served to each of them.
It runs in 74ms. (Internal runtime is 334µs).
from enigma import (enigma, Enumerator, irange, inf, div, subsets, unzip, printf) # set defaults for decompose decompose = enigma.partial(enigma.decompose, increasing=0, sep=0, min_v=1) # solve the puzzle for <n> guests def solve(n): # each guest brings one of: # starfish (5 legs) = x; squid (10 legs) = y; octopus (8 legs) = z for (x, y, z) in decompose(n, 3): # "more people provided octopus than starfish" if not (z > x): continue # calculate the number of legs per guest ts = (5*x, 10*y, 8*z) k = div(sum(ts), n) if k is None: continue # look for a set of n decompositions for ss in subsets(decompose(k, 3), size=n): # that give the correct number of leg types ns = tuple(sum(vs) for vs in unzip(ss)) if not (ns == ts): continue # return solution yield ((x, y, z), k, ss) break # one decomposition is enough # consider the number of guests for n in irange(3, inf): # look for a viable scenario with <n> guests sols = Enumerator(solve(n)) for ((x, y, z), k, ss) in sols: printf("{n} guests ({x} starfish, {y} squid, {z} octopus) -> {k} legs per plate") printf("-> plates = {ss}") # are we done? if sols.count > 0: breakSolution: There were 8 guests. 2 brought starfish, 3 brought squid, 3 brought octopus.
The total number of legs available was: 2×5 + 3×10 + 3×8 = 64 legs.
And so each of the guests was served 8 legs.
The distinct served plates were (starfish legs, squid legs, octopus legs):
Although the program only looks for one way to make up the plates, this is in fact the only way for n = 8.
LikeLike