The problem as given is not well-defined, which is a pretty clear sign that it is
not homework. It is not well-defined because it is unclear what the metric is for the "best" fit. Are we trying to minimize the maximum error? Are we trying to minimize the average error? Are we trying to minimize the sum of the squares of the errors? All three would fit the problem description, and all three can lead to different optimal answers.
The fact that the problem looks NP complete is just icing on the "probably not homework" cake.