0
fastest relay time = lowest possible total integer value of (a freestyle swimmers time) + (1 breastroke swimmers time) + (another backstroke swimmers time) + (another butterfly swimmers time)
- Each swimmer must be unique to the relay (no duplicates)
- Each stroke must be used once
Input Data: array of dictionaries, where each single dictionary represents a swimmer's swim times for each stroke. Each dictionary has the named properties of 'fly','back','breast','free':
Example Input:
[
{'Fly': 10, 'Breast': 48.26, 'Free': 28.43, 'Back': 34},
{'Fly': 47.51, 'Breast': 24, 'Free': 28.47, 'Back': 10},
{'Fly': 26, 'Breast': 46.44, 'Free': 10, 'Back': 30},
{'Fly': 37.81, 'Breast': 10, 'Free': 24, 'Back': 49},
{'Fly': 38.31, 'Breast': 29, 'Free': 20, 'Back': 10}
]
Example Output:
40
(this is an easy case where the best relay is simply the fastest person in each stroke; other times you might need to have the 3rd fastest breastroker swim breastroke in order to get the lowest overall time!)
Example Measurement of a relay using the first 4 swimmers in the data set above:
swimmer 1 swims fly and his time is 10
total += 10
swimmer 2 swims back and his time is 10
total += 10
swimmer 3 swims fly and his time is 10
total += 10
swimmer 4 swims breast and his time is 10
best relay total for these 4 people = 40
Output Data: should be a single float or integer value representing the total time of the best relay. (a legal relay includes a fly swimmer, a back swimmer, a breast swimmer, and a free swimmer, each leg of the relay swam by a unique swimmer)
EDIT: brute force vs dynamic parameter removed.
Could you please provide more information? For example, input format and some test cases. – ProgramFOX – 2014-06-23T08:15:34.490
1How do you measure "fastest"? – justhalf – 2014-06-23T08:27:14.553
The problem statement reads like it requires a brute force solution in order to find an optimal combination - although I do not have a ready proof. – Howard – 2014-06-23T08:27:23.223
@justhalf lowest total time – InfinteScroll – 2014-06-23T08:30:15.650
1@StrikePricer: Yes, my question is exactly "How do you measure which one has the lowest total time?" Is it run on your computer? On some online compiler? On what kind of input? How big is the biggest input? – justhalf – 2014-06-23T08:32:53.107
its a function in a python script i run on my terminal to score a swim meet. this function is run with about 30 swimmers for a single call. this function takes an array of swimmer objects and returns an integer representing the lowest time relay that could be formed – InfinteScroll – 2014-06-23T08:42:06.197
@Howard if no dynamic method is logically possible, then I apologize. :/ . I just assumed there had to be a better way than brute force (I guess I was wrong!). if one were to cull away most of the swimmers except the 4 best ones per each stroke, ___^4 would only be _____, which i guess would be more time acceptable for brute force... – InfinteScroll – 2014-06-23T08:46:54.640
@StrikePricer You can cut all swimmers which have 5th or worse time in all strokes. Unfortunately there is the case of ties and thus the "4" best ones can be more than 4 swimmers. – Howard – 2014-06-23T08:59:38.097
Python 2.7 or 3? – Christofer Ohlsson – 2014-06-23T11:06:00.627