# Formula 1 Grand Prix

For this challenge we are going to use pseudo-code to analyse the timings of the best two formula 1 drivers of the season, Lewis Hamilton and Sebastian Vettel on four different Grand Prix.

For the purpose of this task we will assume that the drivers are competing against each other on four Grand Prix, each race consisting of ten laps only.

The timings of both drivers will be recorded using pseudo-code. Your task will be to analyse the pseudo-code for each of the four grand prix to decide who of the two drivers won each race!

#### Race #1: Australian Grand Prix – Melbourne

Here are the timings of the race:

 Race Timings ```hamiltonTime = 0 vettelTime = 0 for lap in range(1,10): hamiltonTime += 100 vettelTime += 102 if lap==8: hamiltonTime += 18``` Running Commentary Both drivers are on the starting line, ready to push on the accelerator. Lewis Hamilton has a better start and on average completes each lap in 100 seconds (1 minute and 40 seconds) where Sebastian Vettel completes each laps in 102 seconds (1:42). We are now on lap 8 and it seems that Lewis Hamilton is going to win this race. Oh no, Lewis Hamilton is having a technical issue with his car and now needs to stop in the pits to get his car fixed. He has lost 18 seconds! Will he still be able to win the race at the end of lap 10?

Analyse the race above. Can you find out who won this first Grand Prix? Type the name of the winner below:

#### Race #2: British Grand Prix – Silverstone

Here are the timings of the race:

 Race Timings ```hamiltonTime = 0 vettelTime = 0 for lap in range(1,10): if lap <= 4 hamiltonTime += 100 vettelTime += 102 else: hamiltonTime += 103 vettelTime += 102 if lap==9: hamiltonTime += 18 vettelTime += 15 ``` Running Commentary Once again Lewis Hamilton has a better start than Sebastian Vettel and is completing the first 4 laps with an average of 100 seconds (1 minute and 40 seconds) per lap where Sebastian Vettel completes each lap in 102 seconds (1:42). From lap 5 onwards, however Lewis Hamilton seems to be slowing down a bit and is now completing each lap in 103 seconds while Sebastian Vettel remains at the same speed, completing each lap in 102s. He is progressively reducing the gap and catching with Lewis Hamilton. We are now on lap 9 and both drivers decide to have a pitstop losing respectively 18 seconds and 15 seconds. Will this 3-second difference have an impact on the final outcome of this race?

Analyse the race above. Can you find out who won this second Grand Prix? Type the name of the winner below:

#### Race #3: French Grand Prix – Monaco

Here are the timings of the race:

 Race Timings ```hamiltonTime = 0 vettelTime = 0 for lap in range(1,10): hamiltonTime += 103 vettelTime += 101 if lap==5: hamiltonTime +=14 if lap==4 or lap==7: vettelTime += 12``` Running Commentary What a fantastic race from Sebastian Vettel who is taking risks and completing each lap in on average 101 seconds (1:41) whereas Lewis Hamilton is 2 seconds slower on every lap. During this race, Lewis Hamilton will only stop once in the pits, on lap 5 losing 14 seconds whereas Sebastian Vettel will make two stops losing 12 seconds each time. This is a very risky strategy. Which of the two drivers will have made the right decision?

Analyse the race above. Can you find out who won this third Grand Prix? Type the name of the winner below:

#### Race #4: Italian Grand Prix – Monza

Here are the timings of the race:

 Race Timings ```hamiltonTime = 0 vettelTime = 0 for lap in range(1,10): if lap <= 3 hamiltonTime += 101 vettelTime += 101 elif lap>3 and lap<=8: hamiltonTime += 103 vettelTime += 102 else: hamiltonTime += 100 vettelTime += 101 ``` Running Commentary What an exciting start to this race. For 3 full laps both drivers are ex aequo, driving their formula 1 car at exactly the same speed, completing each lap on 101 seconds. From lap 3, Sebastian Vettel is taking the lead, completing laps in 102 seconds, 1 second quicker than his main opponent, Lewis Hamilton. Towards the end of the course however Lewis Hamilton is accelerating progressively closing the gap with Sebastian Vettel. Will he have time to catch up with him and overtake him before the finishing line?

Analyse the race above. Can you find out who won this forth Grand Prix? Type the name of the winner below:

Did you like this challenge?

Click on a star to rate it!

Average rating 2.9 / 5. Vote count: 15

No votes so far! Be the first to rate this post.

As you found this challenge interesting...