Teaser 2437: [Spending money]
From The Sunday Times, 7th June 2009 [link]
My granddaughter Madeline has been shopping. When I asked her the prices of the three items she had bought, she said that each cost less than £10, and that the three prices between them used all the digits 1 to 9. Furthermore, the middle-priced item cost one penny less than three times the cheapest, and the total amount spent was a whole number of pounds.
What were the three prices?
This puzzle was incorrectly published as Teaser 2537.
This puzzle was originally published with no title.
[teaser2437]
Jim Randell 8:23 am on 22 May 2026 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.The following run-file executes in 78ms. (Internal runtime of the generated code is 211µs).
Solution: The prices were: 239p, 716p, 845p.
The total amount spent being 1800p = £18.
LikeLike
ruudvanderham 9:52 am on 22 May 2026 Permalink |
import peek import istr set123456789=set(istr.range(1, 10)) for price2 in istr.range(1, 1000): price1 = 3 * price2 - 1 if price2 < 1000 and (price1 | price2).all_distinct(): for price0 in istr.range(price1 + 1, 1000): if set(price0 | price1 | price2) == set123456789 and (price0 + price1 + price2)[-2:]=="00": peek(price0, price1, price2, price0 + price1 + price2)LikeLike
ruudvanderham 1:37 pm on 22 May 2026 Permalink |
Here’s a different (significantly faster) version:
import peek import istr set123456789 = set(istr.range(1, 10)) for price2 in istr.range(1, 1000): price1 = 3 * price2 - 1 if price2 < 1000: for total in istr.range((price2 + price1 * 2 + 1).ceil(100), 3000, 100): price0 = total - price1 - price2 if price0 >= 1000: break if set(price0 | price1 | price2) == set123456789: peek(price0, price1, price2, price0 + price1 + price2)LikeLike