From e36366c3c81efcba472b688139cf8db87182daf7 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen <62411302+safwan-samsudeen@users.noreply.github.com> Date: Sat, 13 Nov 2021 14:33:31 +0530 Subject: [PATCH] Explain how to find out whether a point is in a circle Add instructions explaining how to find out whether a point is in a circle. This would be helpful so that the student may focus on what's important (programming the solution), and not worry about the mathematical formulas. I spent a lot of time trying to figure out how I could see if the point passed is in the circle, until I came across this (SO post)[https://stackoverflow.com/questions/481144/equation-for-testing-if-a-point-is-inside-a-circle]. I've intentionally only mentioned how to see if the point is _in_ the circle, and not on the circumference (which is part of what the tests check). This is so that the student understands how to change the given formula to solve the problem, instead of direct copy-pasting. Please feel free to make changes as needed. --- exercises/practice/darts/.docs/instructions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/practice/darts/.docs/instructions.md b/exercises/practice/darts/.docs/instructions.md index 701777865e..494b2bfe3b 100644 --- a/exercises/practice/darts/.docs/instructions.md +++ b/exercises/practice/darts/.docs/instructions.md @@ -14,4 +14,6 @@ In our particular instance of the game, the target rewards with 4 different amou The outer circle has a radius of 10 units (This is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1. Of course, they are all centered to the same point (That is, the circles are [concentric](http://mathworld.wolfram.com/ConcentricCircles.html)) defined by the coordinates (0, 0). +To know whether a point is inside a circle (not _on_ the circumference), you can check whether `(x - center_x) ** 2 + (y - center_y) ** 2 < radius ** 2`, where `x` and `y` are the passed coordinates, `center_x` and `center_y` are the coordinates of the center of the circle, and `radius` is the radius of the circle. + Write a function that given a point in the target (defined by its `real` cartesian coordinates `x` and `y`), returns the correct amount earned by a dart landing in that point.