Programming Challenge 28 Published - Get trucking!
Friday September 25, 2009
Only a few days to go for Challenge 27 so get a move on! And from the first of October here's Challenge 28. Write a program that works out the optimal number of trucks and fuel depots to move a large quantity of fuel across a thousand miles of desert.
That's it, but there are a few constraints. There are costs for moving trucks (full and empty) and for setting up fuel depots. You can read all about it at the link below. As usual post comments here if you have any queries..
- Link to Programming Challenge Twenty Eight Optimize Fuel Transport
- Link to Programming Challenge Twenty Seven Pack Cities onto a map


am I missing something?
(the examples don’t help by the way, as they don’t follow the cost rules
you need to setup 3 intermediate depots
(say at 300, 600, 900 miles)
you have one track, traveling loaded all the way through the depots and returning empty
- costs per delivery and back:
4 journeys x 200 salaries = 800
+ 1000 for the 1000 miles carrying fuel
+ 4 journeys back empty x 100 = 400
TOTAL per delivery of 1000 gallons = 2200
now do that 250 times, you have your amount delivered
at a cost of 250×2200 = 550000
if you add another truck, you just incur an extra 15000 cost, but the cost per delivery does not change, you just halve the number of deliveries for each truck. So, no point in buying extra trucks.
All in all, I’m either missing out on something,
or this is well specified, David :-!
I read the description the same way as MakisCE, and reached the same conclusion. Additionally, I was uncertain whether a return trip with an empty truck cost 100 total, or 100 plus the 200 in salary.