Challenge 7
⛳
Golf Scores
3 players play 9 holes of golf. A hole has a 'par' score, which is the expected score a player should achieve on that particular hole
Pars can be 3, 4 or 5. For example, a score of a 5 on a par 3 will be 2 worse than expected, but a score of 4 on a par 5 will be 1 better than expected.
Create an array of pars: [4, 3, 5, 4, 4, 5, 3, 4, 4]
Create a suitable data structure to represent the 3 players' scores. Output the total score to par (e.g. +5, -2 etc) for each player after the 9 holes, the average score of each player on par 3s, 4s and 5s respectively and the overall winner of those 3 players
Examples:
Using the array of pars above, a player scoring [4, 2, 6, 5, 4, 5, 4, 6, 3] would have the following results:
- Score: 39
- Score to Par: +3
- Par 3 Average: 3.00
- Par 4 Average: 4.40
- Par 5 Average: 5.50
Extension:
Output the full leaderboard in order from winner to loser and any additional statistical information - min, max, mean, median, range, standard deviation for either each player or all players combined etc