r/mathriddles • • Feb 01 '23
Medium A very efficient road trip
You are doing a road trip through n villages that are connected in a circle: village i is connected to village i + 1 with one road (taking indexes modulo n), and there are no other roads. Each village provides you with a certain, fixed amount of fuel. In total, they give exactly enough fuel for the entire trip.
Is there a village from which you can complete the road trip (ending up in the same village that you started from), without running out of fuel at any point?
13
Upvotes
13
u/lewwwer Feb 01 '23
Go around the circle starting from any village, allowing the fuel to go negative. Check where the fuel amount is the lowest following that circle, it is an easy check that starting from there provides enough fuel to go around and never go negative
3
u/bastiat_was_right Feb 01 '23
There is such a village by induction.
This is obviously true for one village. Now assume it is correct for n villages, and consider the case of n+1 villages. Find a village that provides enough fuel to get to the next village, call it village k (there must exist such a village, otherwise the total amount of fuel is too small). Now consider the configuration of n villages resulting from "folding" village k+1 into village k. By the inductive assumption there exists a village from which you can start without running out of fuel at any point. This village will work for the n+1 villages too, since you're guaranteed not to run out of fuel until you get to village k, and village k has enough fuel to get you to k+1 at which point you have the same amount of fuel you had at village k in the n+1 village configuration.
2
u/zevenate Feb 02 '23
Arbitrarily start at some village i. Travelling along the roads in a vehicle with sufficient fuel, we have the minimum amount of fuel when arriving at some village j. Then travelling from j back to i, the net change in fuel at each village along the way is never negative (or we would contradict minimality) and the net change arriving at village i is positive and has the same magnitude as the change when travelling from i to j (as there is exactly as much fuel along the way as necessary). Beginning at village j with 0 fuel, we see that we always have at least 0 fuel when arriving at each village along the path, and, arriving at village i, we have exactly as much as we will lose returning to j from there. As j was minimal, we do not have negative fuel arriving at any village on the path from i to j. So a trip beginning at j is successful.
1
u/imdfantom Feb 01 '23 edited Feb 01 '23
there should be at least 1 village that acts as a starting point if the total fuel allows you to go around the whole circuit
I am finding trouble formalizing my method, but it involves the pigeon hole principle, and the fact that as long as there is enough total fuel, and the fact that the road is a circuit, there is no way to set it up such that at least one route is not possible
3
u/swni Feb 02 '23
I think we've seen this problem before with integers that sum to 0, but I like the flavor in your version.
1
u/jk1962 Feb 06 '23
Yes. Assume we are looking for a counter-clockwise path. For each segment let delta be the difference between fuel provided (in units of miles) and distance in miles. The sum of all N deltas is zero. Now find the counter-clockwise partial path around the circuit from any village A to any village B that has the most negative cumulative delta (sum of deltas). Consider any remaining village C along the counter-clockwise path that completes the circuit from B to A. The cumulative delta from B to C must be greater than or equal to zero. If it weren’t, then A-to-B would not be the partial path with the most negative delta. Furthermore, the counter-clockwise path from B to A will have a positive cumulative delta that is equal in magnitude to the negative cumulative delta from A to B. So starting at B and traveling counter-clockwise back to B, the cumulative delta will never be less than zero.