[Community Puzzle] By train or by car?

I removed the duplicated cities.
Tests and validators have been updated and there is no duplicated values. Even if the title is the same, some distances are different.

1 Like

Are tests 7 & 8 so different from others ?
I tried different ways to solve them, but without succeeding. (Test 8 is ok in IDE, but validator not ; Tests 7 are both failed…)
Could it be a float “resolution” problem ?
For instance, Test 7 give me “CAR : 1:48” instead “CAR 1:46”…

Show us your calculation?

Distance can be less than 14.

2 Likes

OHhhhhh… Thx

what to do for distance less than 14?

Only the lower speed is considered.

oh, how silly me, I didn’t understand. Thank You!

Pithiviers Cholet is broken again and Montpellier Perpignan as well (I tripple checked).

Pithiviers Cholet: In order to make the train trip 3:43 hours long as the solution says it is I had to remove all the stops and the 30 minute (walk, bus, car…) trip from the final train station to the final destination.

Montpellier Perpignan: The total distance is 791.7 km which means that the car couldn’t make the trip in 2:27 hours even if it was traveling at the top speed of the train and never slowing down.

So TL;DR:
Pithiviers Cholet should be: "TRAIN 5:09 "
and
Montpellier Perpignan should be: "TRAIN 7:55"

If you have any questions please let me know. I’ll even share my 140 line fully commented debugging script if asked.

Oh and after brute forcing my way passed the two faulty checks I found that validators 4,5,6 and 8 are broken but I don’t have access to troubleshoot those.

Please share the details of how you calculate and arrive at your answers.

How much detail do you want? Also I kind of did in a round about way to avoid posting spoilers.

Similar to the example in the Goal section of the puzzle statement.

OK, I’ll need some time to write that up.

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.]

Didn’t expect you to write that long :sweat_smile: I thought it would be better for you to simplify the explanation like the section “Details by train” in the puzzle statement. Easier to catch your own error that way too…

The issue with your answers: You did not really travel from start to end. You travelled to irrelevant places too - I mean in your calculation.

You did not really travel from start to end.

I’m sorry, I don’t quite understand.

In case 8, you want to go from Montpellier to Perpignan. Are Cholet and Clisson, for example, really required to be part of that journey?

No idea, didn’t look at the map… :stuck_out_tongue_closed_eyes:

I shouldn’t have assumed that the places were all connected. That said the Goal section didn’t exactly mention or hint that not all inputs would be relevant.

All cities will appear only one time as starting point and/or end point. (no loop possible)

I guess that didn’t mean that all cities will appear only one time as starting point and/or end point on the path we need to take.

That said I still think this needs fixing:

The author wrote the goal section in evaluated form and forgot to show his work in some places:

35 + 3*60/50 + 127*60/284 + 3*60/50 + 8 + 3*60/50 + 212*60/284 + 3*60/50 + 30 = 159.01 minutes (2:39)

It should have been written as:

35 + 3*60/50 + (133-3*2)*60/284 + 3*60/50 + 8 + 3*60/50 + (218-3*2)*60/284 + 3*60/50 + 30 = 159.01 minutes (2:39)

He did the operation for his example but didn’t show that he subtracted slow_distance*2 from the distances between Paris ---- 133 km ----> Orléans and Orléans ---- 218 km -----> Tours.

Well the names of the places are provided as inputs for a reason :wink:

As for the calculation, technically the author is not wrong. But I agree that it may not be clear/detailed enough.