Formula One is a complex sport and as with complex sports, strategy is very important.Some teams will manage better strategy than others and those teams will often win the races.
After last weekends' amazing German GP, which saw last years Champion Lewis Hamilton pit 6 times (in comparison, some races just have 1 stop per driver), I was really impressed with all the strategy that was involved by most of the teams. Some really great calls, such as going to soft (from inters) by Racing Point, saw their driver finish 4th which was a rare sight.
Your task will be to suggest what tire configuration should be used for the race.
Here are the 3 available tire types :
All of this data unofficial data, this is unreal data that was made juste for a fun challenge. I tried to keep a little sense in choosing how durable the tires wowuld be, but as I repeat, this is UNOFFICIAL
Name Soft Medium Hard Degradation (per character) 15 10 8 Degradation (per corner) 263 161 128 Time delta (per corner) (ms) 0 +30 +45
There is no time delta on the straights so all tire perform the same
A tires life span is calculated by how many COMPLETE laps it can do before dying. It's health starts at
100 000 and will decrease by the degradation value in the above table.
You will be able to change tires by going to the pits but a pit stop will cost you time.
That time is measured by the distance between P to P (the length EXCLUDES the
Ps on the start/finish straight multipled by 1750 milliseconds.
time for pits = (length between P to P) x 1750 ms
You must just complete the lap on the previous set of tires. So in a way, you are changing them at an imaginary line between the
# and the character before it. Tire degradation in the pits are as if you were driving on track.
A corner is where the characters changes (look at exeption bellow)
All ascii characters can be used for the track (except the exceptions bellow that have specific meaning)
This does not count as a corner, it is just a kink. This is just extra info seeing as the drawings are not considered official and just a representation to give users a better idea or to validate an algorithm.
Ex 1 ______ ______ Ex 2 \ \ \
P does not represent a corner , it is the pit entrance and exit. It still counts in track length though.
# represents the start/finish line (the start and finish line will be the same for the purposes of simplifying things. They also count in track length. The race will start at an imaginary line between the # and whatever comes before it, so yes, the # will degrade the tires when the race starts. The
# is also the first character in the input. You may assume that the last character of the track will be the same as the first character after the start/finish line (
- A list/array of all the characters in order
- A string with all the characters in order
Bonus. The track map drawing made out of the ascii characters (unofficial as it I won't garantee at this point int time that both the drawing and the string bellow are the same
Number of laps:
- An integer, however you want to receive it.
Ex.1 ["_P_#_P_||_______||", 250] Ex.2 ["_","P","_","#","_","P","_","|","|","_","_","_","_","_","_","_","|","|"], 69
The tire strategy with 3 distinct characters to represent the 3 tire compound. Tires can be identified either with letters, numbers, or even words if you want.
You must output all the tires necessary for the race. Tire output must be from softest to hardest compouds.
Ex.1 [S, M, H] Ex.2 [0, 1] Ex.3 [Hard]
TL;DR: find the tire combination that optimizes time delta.
You must use all the tire data (constants) and the race data (track and number of laps, this will be your input) to optimize the best tire strategy (output) in order to minimize the time delta.
A time delta of 0 will be the perfect (but impossible) score, where you would run the soft tires (the fastest) the whole race. Thus, you must use a combinations of tires and run them for how many laps you want as long as it is still in the tires life span. Running soft for the whole race is fastest, but each time you change them at the end of a tire's life span, it will raise your time delta, because you must pit.
- This is code golf so shortest code wins!
- The rest is almost a free-for-all (just don't hard code the answers in!)
Note, drawings are not offial, it is just for representation.
Also, the output aren't checked by another person then me yet, so if you are doing the challenge and find some errors, please notify me.
1. Circuit de Spa-Francorchamps: (yes I know it looks like a gun, but it isn't gun related, I promise, Google the track if you want):
__________ _____^^^ ___________________________ _P_____ \___ <_____#_____P | |_____________ ________ | \ / | | \ / |___| \ | | | | _| | | |______|
#_____<_P__________^^^_____________________________________\___||||___||________//|||_||______||||\\\_____________|P_____ 44 laps per race (according to Wikipedia, Belgian GP 2018)
2. Autodromo Nazionale Monza:
________ \ \ \ \ \ \ \___ \ \ \____ \ \__________________________ \ \ \ / \ _____/___P__#_________P________/
#__P_____/_____\\\\\___\\\\________\\\\\____\__________________________\//________P_________ 53 laps per race (according to Wikipedia, Italian GP 2018)
3. Circuit Gilles Villeneuve:
____ ____| ____ __/ \___________ / ____#___ _______ /P___/ |P______________________>
#____/___P//__/____|________\__________________>______________________P|___ 70 laps per race (according to Wikipedia, Canadian GP 2019)
[Soft, Soft, Medium]
4. Pocono Raceway (not an F1 track, but here to test edge-cases)
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ________P______#_______________P_____
#_______________P_______\\\\\\\\\\\\\/////////////_________P_____ 110 laps per race
Number of laps is innacurate, according to USA Today, it is going to be 160 laps for the 2019 Sunday's Gander Outdoors 400, the 21st race in the Monster Energy NASCAR Cup Series. In F1, races are at least 305km, making any race around this raceway around 76 laps.