Darts: Updating Instructions

After completing and reviewing other submissions, I think that the Euclidean distance formula should be included in the instructions for the darts exercise. Since this is categorized as an easy exercise, it seems to assume knowledge of the formula, but this is more of a mathematical concept than a programming one.

I think it would be helpful to add a brief explanation, such as:

The distance of a point (x,y) from the center (0,0) can be calculated using the Euclidean distance formula: \sqrt{x^2 + y^2}

Tens of thousands of students have managed to complete the exercise. I’m not sure that we want to give away all the details of how to compute the distance; figuring out how to determine distances is (currently) part of the exercise/challenge here. If all exercises provided all the useful computations, I’m not sure if that leaves a ton for students to solve.

I’d love to hear what other maintainers think about this!

I agree with @IsaacG.

Here are my three reasons:

  • IMHO that would make the exercise too simple. It would reduce the (already easy) exercise to implementing a given formula and an chained if or switch construct.
  • It’s not unusual for programmers to have to research some formula, IMHO that’s part of the skill. Asking a search engine for “distance between two points” is on the simpler side.
  • Manually calculating the distance is not the only option. Many programming languages already have a function for calculating the hypotenuse of a rectangular right triangle.
4 Likes

Possibly worth noting, not all solutions actually implement that formula ;) You can solve this without taking any square roots.

4 Likes

Yep, you can just use trigonometry to solve this exercise. The distance formula is just one of the ways to approach the problem.

Yes, that’s what I ususally do in this exercise. No square root, and the constant radii on the target replaced by their squares.