Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Jim Burns <james.g.burns@att.net> |
| Newsgroups | sci.logic |
| Subject | Re: puzzle: Cross the desert |
| Date | Thu, 11 Feb 2016 11:13:34 -0500 |
| Organization | Aioe.org NNTP Server |
| Lines | 249 |
| Message-ID | <56BCB32E.6070904@att.net> (permalink) |
| References | <e46eb715-2ac3-4f34-89c7-a2606d7a57a8@googlegroups.com> |
| NNTP-Posting-Host | DFEBawJ1WznOoYC2BmSJeA.user.gioia.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com sci.logic:141611 |
Show key headers only | View raw
On 2/10/2016 2:00 PM, rdelaney2001@gmail.com wrote:
> You are stranded in a desert, at a base station,
> looking to get home. There's a rescue truck,
> 11 miles away. Along the route, there is a
> series of rest stations, one at each mile.
>
> To make this long trip, you need water. You
> have a wagon, which can carry up to 7 liters.
> You drink one liter of water during the hike
> between each station, forward or backward
>
> Clearly, you cannot make it in one shot. However,
> you may store any quantity of water at the rest
> stations. Hence the solution: a series of hikes,
> back and forth,dropping and picking up water, until
> you ultimately arrive at the rescue point.
>
> What is the minimum initial quantity of water required,
> at the base?
>
> This case isn't hard, as 11 miles is a short
> distance. But imagine it's 20 to the rescue station,
> that would be a lot of work!
>
> Note the problem statement: not merely to find
> a procedure to reach safety, but also minimizing
> the store of water. So, for a long walk, you
> could find an algorithm solution; but how would
> you show your algorithm is optimal?
Yesterday, I gave what seems to me to be a good start
on answering your question.
<https://groups.google.com/d/msg/sci.logic/rp_4tkC_AKE/ddKFWYSPEwAJ>
I wrote out a recursive relationship for how much water
is _necessary_ to cross m miles of desert.[1]
After thinking a bit more, I have convinced myself that
the minimal solution that I gave for crossing 11 miles
of desert generalizes (using instructions that are pretty
obvious in hindsight).[2]
If I'm right, the _necessary_ number of liters is also a
_possible_ number of liters, the recursive relation I gave
is the number of liters needed, and the instructions tell
how to distribute them. That would be most of what you ask for.
The last part of your question, proving my solution is optimal,
depends upon me defining my terms properly, I think, and
I haven't done that. A good part of the proof is done if I
can show I have an optimal process for a task like:
Your base is at mile marker 20. Optimally place 97 liters
of water at mile marker 19. Then, continue with the
optimal process for a base at mile marker 19, picking
up a bottle from that station as you pass through in
either direction.
It seems obvious to me that the optimal process for this
sub-task is:
Load up with 7 bottles, walk a mile out, drop off 5 bottles,
walk a mile back. Repeat. The last time, load up with
4 bottles and drop off 2.
I calculated the minimum water necessary to cross m miles
by reducing it to the problem of crossing that first mile some
number of times and the problem of crossing the m-1 miles
left. As you see, my instructions for distributing the
water follows the same pattern, so I don't expect a snag
to appear.
----
[1]
The rescue truck is at mile 0, and the rest stations are at
miles 1, 2, 3, ... , m-1 . If the base with all the water is at
mile m, what is minimum amount of water needed to cross m miles?
WATER(m) = the minimum water needed to cross m miles, with the
base at mile m
cross(m) = the number of times I cross mile m to mile m-1
or mile m-1 to mile m
WATER(m) = WATER(m-1) + cross(m)
If the base is at mile m, and I leave the base some number of
times, LEAVE(m), optimally distributing and using water, the
most water I could take is 7*LEAVE(m) . That cannot be less than
the water needed to cross m miles.
7*LEAVE(m) >= WATER(m)
(I need to add an obvious constraint. I will pass through
each rest station at least once, on my way to the rescue truck.
When I left that out, my formula came out wrong at miles 1 and 2.)
LEAVE(m) >= 1
Every time I leave the base, I return, except for the last time,
so the number of times I cross ( m, m-1) is
cross(m) = 2*LEAVE(m) - 1
After a bit of sorting out,
LEAVE(m) = max( 1, ceiling((WATER(m-1) - 1)/5) )
WATER(m) = WATER(m-1) + 2*LEAVE(m) - 1
WATER(0) = 0
miles water leave
0 0
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
6 6 1
7 7 1
8 10 2
9 13 2
10 18 3
11 25 4
12 34 5
13 47 7
14 66 10
15 91 13
16 126 18
17 175 25
18 244 35
19 341 49
20 476 68
----
[2]
I see I don't have my instructions perfectly written down,
(Note lines with '(?)') but it's pretty close. It should be
obvious what needs to be done at each step. I just haven't
thought out what tests could be done to decide whether I am
at that step or not.
Giving instructions for distributing the water is easiest if we
count back from the last trip, which crosses all the way to
the rescue truck, trip = 0, _preceded_ by a trip that stops about
7 miles from the truck and turns back, trip = 1, and so on.
(I notice 'trip' is the number of trips left.)
Each trip has a goal, the number of bottles water that I want
to see at each rest station that I come to. If the rest station
has more, I take a bottle and go on. If it has too few, I leave
whatever bottles I can, keeping enough to return to base.
(The number I keep should always be 1 bottle, because I should
have previously stashed enough bottles in the higher-mileage
rest stops.)
The goal gets smaller for every trip, because the number of times
I will need to pass through and take a bottle gets smaller for
every trip.
goal(0) = 0
goal(trip) = 2*trip - 1
Consider the 20-mile solution:
trip = 67, goal = 133
load 7
walk to 19
cache(19) = 0 < goal = 133
then drop 5 and go back
walk to 20
trip = 66, goal = 131
load 7
walk to 19
cache(19) = 5 < goal = 131
then drop 5 and go back
walk to 20
...
trip = 48, goal = 95
load 7
walk to 19
cache(19) = 95 = goal = 95
then take 1 and go forward
walk to 18
cache(18) = 0 < goal = 95
then drop 5 and go back
walk to 19, take 1
walk to 20
trip = 47, goal = 93
load 7
walk to 19
cache(19) = 93 = goal = 93
then take 1 and go forward
walk to 18
cache(18) = 5 < goal = 93
then drop 5 and go back
walk to 19, take 1
walk to 20
...
trip = 1, goal = 1
load 7
walk to 19
cache(19) = 3 > goal = 1
then take 1 and go forward
walk to 18
cache(18) = 3 > goal = 1
then take 1 and go forward
...
walk to 10
cache(10) = 3 > goal = 1
then take 1 and go forward
walk to 9
cache(9) = 0 < goal = 1
then drop 1 and go _forward_ (?)
walk to 8
cache(8) = 0 < goal = 1
then drop 1 and go back
walk to 9, take 1
walk to 10, take 1
...
walk to 20
trip = 0, goal = 0
load 7
walk to 19
cache(19) = 1 > goal = 0
then take 1 and go forward
walk to 18
cache(18) = 1 > goal = 0
then take 1 and go forward
walk to 17
cache(17) = 1 > goal = 0
then take 1 and go forward
...
walk to 7
cache(7) = 0 = goal = 0
then _don't_ take 1 and go forward (?)
...
walk to 0
start rescue truck. Keys!
slap forehead.
Back to sci.logic | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
puzzle: Cross the desert rdelaney2001@gmail.com - 2016-02-10 11:00 -0800
Re: puzzle: Cross the desert Jim Burns <james.g.burns@att.net> - 2016-02-10 21:45 -0500
Re: puzzle: Cross the desert Jim Burns <james.g.burns@att.net> - 2016-02-11 11:13 -0500
Re: puzzle: Cross the desert Justin Thyme <JustinThyme@nowhere.com> - 2016-02-11 16:44 +0000
Re: puzzle: Cross the desert Justin Thyme <JustinThyme@nowhere.com> - 2016-02-11 16:59 +0000
Re: puzzle: Cross the desert Justin Thyme <JustinThyme@nowhere.com> - 2016-02-11 17:02 +0000
csiph-web