Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.programming Subject: Re: Problem C++ gas tank refuel Date: Wed, 15 Dec 2021 12:59:20 +0000 Organization: A noiseless patient Spider Lines: 23 Message-ID: <87lf0myqfr.fsf@bsb.me.uk> References: <8fd306f3-1cdc-439b-a82c-458f9b926418n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="5f596f9237df6631f4c71dc6171515d7"; logging-data="15316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CA5RyTCK5HV9yx/rxtZO0uX8oWQeQT38=" Cancel-Lock: sha1:MrWWd06HENsfqzR3KMGJ7aeqs6Y= sha1:NaamxywluGr1t4zjP3qyIbK4WDk= X-BSB-Auth: 1.654e4edc01d7beb165d5.20211215125920GMT.87lf0myqfr.fsf@bsb.me.uk Xref: csiph.com comp.programming:14338 Darioes writes: > Hi guys, > > Im programing a new exerciese that i need to do for a college project, in C++. > > That project consists in implementing an algorithm that just goes the > minimal ways, not like Dijkstra’s algorithm but something similar: You > are have a car, that needs to go from France to Corea and you need to > refil your gas tank . You need to pick the minimal ways so that the > car's fuel tank is as low as possible. That last phrase is a little confusing. The stages that make up the final route have costs, and the route with the minimum cost is to be found. Look up depth first search. I would do this recursively. Keep a note of the least cost so far and update it every time the search reaches the destination. When a search exceeds the least cost so far, update it. Lots of details remain for you to work out... -- Ben.