The great Dudeney, bless his soul, created, inter alia, the following puzzle:
There was a man who lived on a XXXX street numbered 1,2,3 … etc. on his side and all the following numbers on the other side of him.
The numbers on both sides added to exactly the same amount.
What was the number of the last house?
I have slightly changed the original wording and also took the liberty of coding a single 4 letter word of his text to avoid getting a trivial solution.
I ask for a solution which is over 45. The upper limit stays open.
So:
a. Provide an answer (or answers) 46 and up.
b. What word was replaced by XXXX?
Bonne chance!
At first I was unsure of the meaning of "side of him" but I think it means:
... for house number N where number of houses is H, sum[1 to (N1)] = sum[(N+1) to H]
For example if the number of houses were 8 and his house number was 6,
then 1+2+3+4+5 = 7+8
(a). My answer is the Last House number is 49, and the man lives at #35.
(b). And XXXX stands for "LONG"
n(n1)/2 = h(h+1)/2  n(n1)/2  n
n(n1) = h(h+1)/2  n
2n^2  2n + 2n = h^2 + h
2n^2 = h^2 + h
h^2 + h  2n^2 = 0
h = [1 +/ sqrt(8n^2 + 1)] / 2
n h the two sums
1 1 0
6 8 15
35 49 595 < House number over 48
204 288 20706
1189 1681 706266
6930 9800 24008985
40391 57121 815696245
235416 332928 27710228820
1372105 1940449 941335379460
7997214 11309768 31977711882291

def tri(n):
""" input an integer, returns the nth triangular number. """
return int(n*(n+1)/2)
def isSquare(n):
""" Input an integer, Returns True iff it is a perfect square. """
if round(n**0.5)**2 == n:
return True
else:
return False
ans = []
for i in range(1,10000000):
x = (8*(i*i) + 1)
if isSquare(x):
h = (1 + (8*(i**2) + 1)**.5 ) / 2
print(i,int(h),tri(i1))
ans.append(int(h))
Edited on May 31, 2022, 9:10 am

Posted by Larry
on 20220531 09:08:38 