- Joined
- Oct 6, 2022
- Messages
- 3
- Reaction score
- 0
Hi.
From university I got this problem below, which I can't solve. They want it written in C# in which I have no knowledge of. I was hoping if someone here can help me with it.
Here is the problem:
We have 3 barrels with 100L fuel each.
Also a truck with 20L fuel tank and it can carry 1 barrel.
The truck consumes 10L per 100km (10L / 100km).
With this we have to figure out how to move the barrels and consume the fuel inside them in the most efficient way so that we can travel the most distance in a straight line. The truck can move, and refill from, which ever barrel he wants.
The truck can travel 3000km with all the fuel in the barrels. In a straight line I believe the truck can travel 1500km. That's the most optimal I got on paper but for the love of god I can't translate it to code.
I got that answer by refilling from a barrel, getting a full barrel for 100km drop it and with the rest go back for the next full barrel and refilling from the same barrel, then going back for the not full one. And that left me with 2 100l barrels and one with 40l left. (100km straight and 500km overall). Repeat that again and we're left with 2 100l barrels, 1 0l and an empty fuel tank. After that we do that again with the 2 barrels until the barrel we refill from is left at 40l, then we move the emptier barrel first and refill once from the full barrel so we don't redundant paths. After that we empty the barrels and 1500km straight/3000km overall is achieved.
I guess I should say that I have to do it till December 1.
Thank you in advance for all the help provided.
From university I got this problem below, which I can't solve. They want it written in C# in which I have no knowledge of. I was hoping if someone here can help me with it.
Here is the problem:
We have 3 barrels with 100L fuel each.
Also a truck with 20L fuel tank and it can carry 1 barrel.
The truck consumes 10L per 100km (10L / 100km).
With this we have to figure out how to move the barrels and consume the fuel inside them in the most efficient way so that we can travel the most distance in a straight line. The truck can move, and refill from, which ever barrel he wants.
The truck can travel 3000km with all the fuel in the barrels. In a straight line I believe the truck can travel 1500km. That's the most optimal I got on paper but for the love of god I can't translate it to code.
I got that answer by refilling from a barrel, getting a full barrel for 100km drop it and with the rest go back for the next full barrel and refilling from the same barrel, then going back for the not full one. And that left me with 2 100l barrels and one with 40l left. (100km straight and 500km overall). Repeat that again and we're left with 2 100l barrels, 1 0l and an empty fuel tank. After that we do that again with the 2 barrels until the barrel we refill from is left at 40l, then we move the emptier barrel first and refill once from the full barrel so we don't redundant paths. After that we empty the barrels and 1500km straight/3000km overall is achieved.
I guess I should say that I have to do it till December 1.
Thank you in advance for all the help provided.