Friday, February 20, 2009

Puzzle: House Numbers

Presenting a simple but interesting puzzle.

Problem:
You live on a street with N houses, where N is between 50 and 500. The houses are numbered consecutively from 1 to N and are all on one side of the street. You notice that all the numbers on one side of your house add up to exactly the same total as all the numbers on the other side of your house. What is the number of your house?

Solution: Let 'x' be your house number. Then,

sum (i=1 to x-1){i} = sum(i=x+1 to n){i}

x(x-1)/2 = {n(n+1)/2 - x(x+1)/2}

x(x-1) + x(x+1) = n(n+1)

x^2 = n(n+1)/2

Looking at this equation, the conclusion is that the value of n should be such that:
- n/2 and (n+1) are both themselves squares, or,
- n and (n+1)/2 are both themselves squares

A simple C program indicates that the value of n is 288 and your house number is therefore, 204.

No comments: