To illustrate my solution process I’ll use Montpellier Perpignan.
Montpellier Perpignan
18
Cholet Clisson 35.9
Beziers Narbonne 34.2
Orleans Blois 63
Montpellier Beziers 73.1
Tours Saumur 78
Angouleme Jarnac 33.2
Jarnac Cognac 11
Cognac Saintes 28.1
Saintes Saujon 27.7
Saujon Royan 13.3
Clisson Nantes 33.7
Blois Tours 65
Angers Cholet 65
Saumur Angers 66
Narbonne Roquefort-des-Corbieres 27
Salses-le-Château Perpignan 17.6
Paris Chartres 91
Roquefort-des-Corbieres Salses-le-Château 28.9
First I put all the distances in a list (I’m using python btw):
distances = [35.9, 34.2, 63.0, 73.1, 78.0, 33.2, 11.0, 28.1, 27.7, 13.3, 33.7, 65.0, 65.0, 66.0, 27.0, 17.6, 91.0, 28.9]
# sum(distances) = 791.7
==== Train Part ====
Next up I put the information train information from the Goal section of the puzzle into variables:
time_to_start_station = 35 # minutes
train_fast_speed = 60/284 # min/km
train_slow_speed = 60/50 # min/km
train_slow_distance = 3 # km
train_slow_time = train_slow_distance * train_slow_speed # minutes
train_stop_time = 8 # minutes
time_from_end_station = 30 # minutes
Now I add:
time_to_start_station + time_from_end_station + # Start + Enf
train_stop_time * distances_length + # Total stop time
distances_length * train_slow_distance * 2 * train_slow_speed + # Total slow time
(sum(distances) - train_slow_distance * 2 * distances_length) * train_fast_speed
# Total fast time
And we get train_time = 475.043661971831
minutes or 7:55
hours.
==== Car Part ====
For the car I again create and assign variables for the information we know about traveling by car:
car_fast_speed = 60/105 # min/km
car_slow_speed = 60/50 # min/km
car_slow_distance = 7 # km
car_slow_time = car_slow_distance * car_slow_speed # minutes
I split the distances
to separate values < 14
big_distances = [35.9, 34.2, 63.0, 73.1, 78.0, 33.2, 28.1, 27.7, 33.7, 65.0, 65.0, 66.0, 27.0, 17.6, 91.0, 28.9]
little_distances = [11.0, 13.3]
Now I add:
sum(little_distances) * car_slow_speed + # Little Distances slow time
big_distances_length * car_slow_distance * 2 * car_slow_speed + # Big Distances slow time
(sum(big_distances) - car_slow_distance * 2 * big_distances_length) * car_fast_speed
# Total fast time
And we get car_time = 608.4742857142859
minutes or 10:08
hours.
Since 7:55
hours is significantly less than 10:08
hours the train is faster.
[EDIT/Summary: My approach here is to sum up all the time travelled for all the distances provided - the original wall of text can be found in the previous version of the message.]