Teaser 2449: [Numbers of marbles]
From The Sunday Times, 30th August 2009 [link]
George and Martha gave their grandson nine plastic cups, numbered 1 to 9, and 45 marbles. They asked him to place one marble in cup 1, two in cup 2, etc.
A while later he had indeed used all the marbles, placing a different number in each cup, but no cup contained the correct number. The child explained the task was too easy, so, for each cup, he had multiplied its number by George and Martha’s two-digit house number, added up the product’s digits, looked at the units digit of that sum, and placed that number of marbles in the cup.
What is the house number?
This puzzle was originally published with no title.
[teaser2449]
Jim Randell 8:12 am on 27 March 2026 Permalink |
This Python program runs in 69ms. (Internal runtime is 379µs).
from enigma import (irange, dsum, printf) # solve for house number h def solve(h): ns = list() for i in irange(1, 9): # perform the procedure n = dsum(i * h) % 10 # values cannot be in the correct position, or repeated if n == i or n in ns: return ns.append(n) return ns # consider 2-digit house numbers for h in irange(10, 99): ns = solve(h) # check 45 marbles are used if ns and sum(ns) == 45: # output solution printf("{h} -> {ns}")Solution: The house number is 94.
Which gives rise to the following sequence of numbers:
LikeLike
Ruud 8:43 am on 27 March 2026 Permalink |
import istr istr.repr_mode("int") for house_number in istr.range(10, 100): amounts = [sum(cup_number * house_number)[-1] for cup_number in range(1, 10)] if sum(amounts) == 45 and all(amount != cup_number for cup_number, amount in enumerate(amounts, 1)): print(house_number, amounts)LikeLike
Jim Randell 9:07 am on 27 March 2026 Permalink |
@Ruud: Does this ensure that there are a different number of marbles in each cup?
LikeLike
Ruud 9:22 am on 27 March 2026 Permalink |
You are right.
The code should read
import istr istr.repr_mode("int") for house_number in istr.range(10, 100): amounts = [sum(cup_number * house_number)[-1] for cup_number in range(1, 10)] if sum(amounts) == 45 and all(amount != cup_number for cup_number, amount in enumerate(amounts, 1)) and len({*amounts}) == 9: print(house_number, amounts)LikeLike