We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d7485b3 commit 3a2ea57Copy full SHA for 3a2ea57
darts/darts.py
@@ -1,5 +1,7 @@
1
"""Darts is a game where players throw darts at a target."""
2
3
+from math import sqrt
4
+
5
6
def score(x: int, y: int) -> int:
7
"""
@@ -16,4 +18,12 @@ def score(x: int, y: int) -> int:
16
18
:param y: The y-coordinate where the dart landed
17
19
:return: The points scored (0, 1, 5, or 10)
20
- pass
21
+ # Calculate distance form the center of the circle (0, 0)
22
+ distance: float = sqrt(pow(x, 2) + pow(y, 2))
23
+ if distance > 10:
24
+ return 0
25
+ if distance > 5:
26
+ return 1
27
+ if distance > 1:
28
+ return 5
29
+ return 10
0 commit comments