Dear swi prolog community,
i have an assignment for my university class in prolog. If you can help me in anyway, i would appreciate it.
First of all the task.
We have to write a ‘function’ which sums up the flight time of route numbers. the route numbers are given in a list. If the destination of an route differs from the startpoint of the following route, we need to add 3 hours to the flight time because the aircraft needs to remove itself to the new startpoint.
For example: if we have the list [1,2], it means we have an aircraft flying from FRA to LHR and after this from FCO to FRA. So the total flight time would be 210 minutes ( it is okay to output it as minutes ), but we have to add another 3 hours to it, because the landingpoint LHR differs from the following startpoint FCO. So in total we would have 390 minutes.
If anyone knows how to do it or can help me in anyway, I would really appreciate it.
This is the data we have
Currently i am thinking about something like
sumlist([],0).
sumlist([H|T],Sum):-
sumlist(T,SumRest), Sum is H + SumRest.
but i don’t know how to solve the problem if the startpoint and landing point are different.
Many thanks