There are 5 neighbors living on a straight road, one of whom needs to host a party. If the distances between neighboring houses are as written, who should host the party to minimize the total distance walked?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
In all cases, for any number of houses, just pick the median of the houses.
Log in to reply
I think you are right. But how do we prove it.
Log in to reply
I need to prove it. When I have time I will do it, regards.
Log in to reply
@Ossama Ismail – I am trying too.
Log in to reply
@Chew-Seong Cheong – https://brilliant.org/problems/where-is-the-gas-station-2/?ref_id=1303666
Ossama, I did it.
Log in to reply
This is great .. thank you ... 👍😎😁
Did you delete your proof ???
Log in to reply
@Ossama Ismail – Yes, and replace with a simpler one.
The median house is the green one, not the yellow. Besides, consider the math above proves this right: it's 140 for the yellow house and 130 for the green. How can you refute this?
Note: There's a much easier way to prove the general case
Hint: Pair off the endpoints.
Considering the yellow house the distance covered is: 50+0+10+(10+20)+(10+20+20)=140 Considering the green house the distance covered is: (50+10)+10+0+20+(20+20)= 130
If we consider the function the describes the distance covered considering a general meeting point x (Considering the left one to be at x=0 (origin))...
We have: d(x)= |x|+|x+50|+|x-60|+|x-80|+|x-100|
d(x) got a minimun on x=60, d(60)=130.
What ia wrong on my approach?
P.s. |x| = absolut value
The middle house (or median) is actually the green house. The actual distances traveled also prove that it should be the green one; 140 for the yellow house and 130 for the green.
Log in to reply
Thanks for notifying us. When we updated the image, we changed the colors but forgot to update the answer. Those who answered green have been marked correct.
In future, if there is an issue with the problem, you can report it directly by selecting "Report problem" from the menu.
I have noticed the question was changed. I have changed the answer too.
It has to be always the middle house. If you move the party from not the middle house to the next one being more in the middle you save the distance between those 2 houses for one more man.
If you change from the yellow to the green brown and yellow must go a longer distance but pink green and blue a shorter. So it is 2 to 3.
Since distances are all given. Simply calculate total distances and you'll find that Green house has lowest total distance.
Problem Loading...
Note Loading...
Set Loading...
Thanks to @Calvin Lin for this simple proof.
This is to prove that:
Let there be an odd number of houses, H 1 , H 2 , H 3 , ⋯ , H n . First consider the two end houses H 1 and H n . We note that the total distance the two neighbors need to walk is the distance between them. Similarly for H 2 and H n − 1 , the total distance the two neighbors walk is the distance between H 2 and H n − 1 if the party is held in a neighbor's house in between their houses. If the party is held in H 1 or H 2 , the two neighbors of H 2 and H n − 1 need to walk an extra distance of twice the distance between H 1 and H 2 or H n − 1 and H n respectively. For the same reason, the shortest distances walked by the pair of neighbors H 3 and H n − 2 , H 4 and H n − 3 and so on are minimum if the party is held in house in between their houses. It is obvious that the overall distance walked by all the pairs of neighbors is minimum if the party is held in the house in the middle. In this problem the middle house is the Green House. The minimum total distance walked is the sum of the distances between the paired houses.
For even number of houses either one of the two houses in the middle can hold the party to give the minimum total distance walked.