[Community Puzzle] By train or by car?

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @nguyen.lam,validated by @FoXbOw,@alze and @Stl.
If you have any issues, feel free to ping them.

I think this is a great puzzle. I’m curious, doesn’t test case 6) violate the constraints?

“All cities will appear only one time as starting point and/or end point.”

Pithiviers Cholet
8
Poitiers Angouleme 138
Pithiviers Orleans 57
Orleans Blois 63
Blois Tours 65
Bordeaux Tours 138
Tours Saumur 78
Saumur Angers 66
Angers Cholet 65

i’ve removed an extra white space from test case 3. It probably didnt affect most people because you’ve provided the number of links but i used open(0) to read the entire file.

This puzzle has a terrible design:

  • The statement is wrong because some test cases have cities appearing more than two times
  • I wrote my solution based on the “no more than two times” constraint and it worked which means tests and validators are badly designed
  • Some validators are mere copies of the tests
  • The stub is poorly engineered. It reads entire lines instead of separating variables
1 Like

Good points to pick up.
Besides them, there ought to be cases where two cities have a distance of less than 6 or less than 3, as edge-cases to enforce better implementations.

Hi,
Thank you for the feedback.
I changed test 6 to respect the constraint: “All cities will appear only one time as starting point and/or end point.”

Pithiviers Cholet
8
Poitiers Angouleme 138
Pithiviers Orleans 57
Orleans Blois 63
Blois Tours 65
Bordeaux Périgueux 137
Tours Saumur 78
Saumur Angers 66
Angers Cholet 65

I updated some validators as well…

Sorry, I double check the input for test case 3 , I can’t see white space.

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.