Teaser 2523: [Unusual Avenue]
From The Sunday Times, 30th January 2011 [link] [link]
George and Martha moved to a two-figure house number in Unusual Avenue. The avenue runs from south to north and each house is directly opposite another. No 1 is the southernmost on the west side, then the houses run consecutively up the west side, then southwards back down the east side. So, No 1 is opposite the highest-numbered house.
George and Martha’s number is a multiple of the number of the house opposite. The same is true of the five houses their daughters live in, but all their houses have three-figure numbers.
How many houses are there in the avenue?
This puzzle was originally published with no title.
[teaser2523]
Jim Randell 9:42 am on 6 May 2025 Permalink |
If there are k houses on each side of the road, then opposite houses sum to (2k + 1).
There are 2k houses on the road in total, and the number of George and Martha’s house n is a 2-digit number that is a multiple of the house opposite (which has number 2k + 1 − n).
Hence:
And the maximum possible 2-digit value for n is 99, hence:
This gives us an upper bound for an exhaustive search.
The following Python program runs in 56ms. (Internal runtime is 332µs).
from enigma import (irange, group, ndigits, printf) # consider possible k values (number of houses on one side of the road) for k in irange(52, 98): t = 2 * k # total number of houses # collect numbers that are a multiple of the house opposite ns = list(x for x in irange(k + 1, t) if x % (t + 1 - x) == 0) if len(ns) < 6: continue # group the numbers by digit count g = group(ns, by=ndigits) # ensure there is a 2-digit and 5 3-digits (n2s, n3s) = (g.get(2), g.get(3)) if (not n2s) or (not n3s) or (len(n3s) < 5): continue # output solution printf("total houses = {t} [n2s={n2s} n3s={n3s}]")Solution: There are 134 houses in the road.
And so the numbers of opposite houses sum to 135.
George and Martha live at 90, which is opposite 45.
And there are 6 houses that their 5 daughters could live at:
If instead of an Avenue the road was a Close, with a house at the closed end (or several houses), then there would be further possible solutions.
LikeLike
Frits 12:39 pm on 8 May 2025 Permalink |
Using ideas of Jim and Brian.
# the number of houses is even, say 2.k, so we want numbers # n such that: # # n = m.(2.k + 1 - n) ==> (m + 1).n = m.(2.k + 1) # # this makes both n and m even (credit: B. Gladman) d3 = 5 # five 3-digit numbers mn = 49 + d3 # 2.k >= 100 + (d3 - 1) * 2 mx = (3 * 99 - 2) // 4 # n >= 2 * (2k + 1) - n # are there at least <a> house numbers with correct opposite house number? def find(k, a, strt, m=-1): c, x, k2 = 0, strt, k + k while c <= a and x >= m: c += (x % (k2 + 1 - x) == 0) x -= 2 return c >= a # consider possible k values (number of houses on one side of the road) for k in range(mn, mx + 1): # opposite housenumbers t.m / (m + 1) and t / (m + 1) with t = 2.k + 1 # t.m / (m + 1) <= 98 or m <= 98 / (t - 98) m = 98 // ((k2 := k + k) - 97) # check for solutions of even n less than 100 if any((k2 + 1) % x == 0 for x in range(3, m + 2, 2)): # check for at least <d3 - 1> solutions for even numbers # in range 100 ... 2.k - 2 if find(k, d3 - 1, k2 - 2, 100): print("answer:", k2)LikeLike