Problem 43667. Use a timetable to analyze a train timetable (Part 4)
Solution Stats
Problem Comments
-
4 Comments
Could you be more specific on the underlying relationship between the input (timetable) and output (mean duration)? That is, among which group are you calculating the mean duration? From your example, there are only 2 groups of destinations, i.e., BOS and NYC, but why there are 3 values in the output? What's the mapping behind? Also, your problems including Part 1, 4, 5 are all based on single test, which allows hard-coded solution to lead.
Peng do share the grouping method cause it eludes me :)
There seems to be an error with the test suite: the first mean time should be 03:09:50 and not 03:09:05. And the test code should probably be abs(ttDur - Dur) <= duration([0 0 1]) (not 0.01).
The test suite has been updated to use 03:09:50. Also, the check for each of the three average durations is made against 0.0001 now, instead of 0.01, to ensure 03:09:05 will not pass (as that was incorrect). Finally, the test suite now accommodates a row vector (in addition to the expected column vector) as the function output.
Solution Comments
-
1 Comment
This is not a solution. It returns just a single value instead of 3 and somehow works.
-
2 Comments
Eventually figured out the grouping method in this problem, which is not so obvious...
This is a proper solution and with small size.
Problem Recent Solvers52
Suggested Problems
-
Find state names that end with the letter A
1036 Solvers
-
Project Euler: Problem 10, Sum of Primes
1324 Solvers
-
Getting the indices from a vector
7099 Solvers
-
Sum of odd numbers in a matrix
446 Solvers
-
Words Count: A String Array Approach
63 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!