Given a list of hole yardages, green sizes, a slice angle and a max distance, compute a golf score.
Assumptions
- Earth is flat
- All greens are circular
- Slice angle will be between -45 and 45 degrees and will be given in degrees
- All distances in the same metric (yards or meters, doesn't matter)
- No out of bounds, obstructions or doglegs
- Max score on any hole is 8
- All shots travel the lesser of max distance or distance to the hole, in a direction defined by the angle to the hole plus the slice angle.
- Distance is measured as the straight line or Euclidean distance between the start and end point.
- Max distance and slice angle are the same for all shots on all holes
- The golfer always two-putts once on the green (or exactly on the edge of the green).
Example
Let's look at the hacker from the test case #5 below for hole #2. The hacker can hit the ball 320 yards, but always slices 30 degrees. If we assume without loss of generality that the tee box is at {0,0} and the green is at {497,0}, then he will hit shots to the following points, arriving on the green with the 7th shot:
{{0.,0.},{277.128,-160.},{547.543,-131.372},{569.457,7.67088},{502.872,37.2564},{479.159,7.92741},{490.646,-7.85868},{500.078,-4.22987}}
At this point, his score would be 9 due to the two putts required, so the final score for him gets capped at 8, per the assumptions.
Graphically, it will look like this:
Test Cases
All the test cases have standard 18-hole courses
Case#1
{MaxDistance->280,SliceAngle->10,HoleDistances->{181,368,161,416,158,526,377,427,509,148,405,443,510,494,396,388,483,172},GreenDiameters->{26,18,17,23,27,23,21,23,25,21,19,24,21,23,25,24,22,22}}
Scores:
{4,5,4,5,4,5,5,5,5,4,5,5,5,5,5,5,5,4}
Output: 85
Case#2 (same course as Test Case #1, shorter more accurate golfer)
{MaxDistance->180,SliceAngle->5,HoleDistances->{181,368,161,416,158,526,377,427,509,148,405,443,510,494,396,388,483,172},GreenDiameters->{26,18,17,23,27,23,21,23,25,21,19,24,21,23,25,24,22,22}}
Scores:
{4,5,4,5,4,6,5,5,6,4,5,5,6,6,5,5,5,4}
Output: 89
Case#3 (Same golfer as test case #1, shorter course)
{MaxDistance->280,SliceAngle->10,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{4,5,4,5,5,4,4,4,4,5,5,5,4,4,5,5,5,5}
Output: 82
Case#4 (Same course as test case #3)
{MaxDistance->180,SliceAngle->5,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{3,6,3,6,5,4,4,3,3,5,5,5,3,3,5,5,6,5}
Output: 79
Case#5 (Hacker)
{MaxDistance->320,SliceAngle->30,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{6,8,5,8,7,6,6,6,6,8,8,8,6,6,8,8,8,8}
Output: 126
Rules
- Any format can be used for the input. Output is simply the number of simulated strokes, so should be an integer.
- This is code-golf so the shortest answer in bytes wins. Standard loopholes apply.
MaxDistance
of the hole? \$\endgroup\$GreenDiameter/2
, in which case yes, since score is capped at 8 and there are always 2 putts. \$\endgroup\$