Your pleasure function is a second-degree function that includes the points
... (1, 18), (2, 35), (3, 51)
There are a number of ways you can determine the function's coefficients, including writing a system of equations, using Lagrange interpolating polynomials, or using quadratic regression on your calculator. The pleasure function p(h) is
... p(h) = (h/2)(37-h)
The cost function c(h) gives the amount you must pay for playing h holes. It is
... c(h) = 25 + 0.5h
The difference between these functions will be the excess of pleasure over cost. We could call it the joy function j(h). It will be
... j(h) = p(h) - c(h)
... j(h) = -0.5h² +18h -25
This will have a maximum at h= -b/2a = -18/(2·(-0.5)) = 18. (a, b refer to the x² and x coefficients in ax²+bx+c, the standard quadratic form)
For maximum joy, you will play 18 holes of golf.