From 95ba1e4e645c83f5bfa517f17c0f70382cde4d0e Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 03:48:33 +0000 Subject: [PATCH 1/5] [Sync Iteration] python/darts/1 --- solutions/python/darts/1/darts.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 solutions/python/darts/1/darts.py diff --git a/solutions/python/darts/1/darts.py b/solutions/python/darts/1/darts.py new file mode 100644 index 0000000..d65a3f7 --- /dev/null +++ b/solutions/python/darts/1/darts.py @@ -0,0 +1,19 @@ +"""Darts is a game where players throw darts at a target.""" + + +def score(x: int, y: int) -> int: + """ + Calculate the points scored in a single toss of a Darts game. + + Given the x and y coordinates where a dart lands, returns the score + based on the distance from the center (0, 0): + - Inner circle (distance <= 1): 10 points + - Middle circle (distance <= 5): 5 points + - Outer circle (distance <= 10): 1 point + - Outside target (distance > 10): 0 points + + :param x: The x-coordinate where the dart landed + :param y: The y-coordinate where the dart landed + :return: The points scored (0, 1, 5, or 10) + """ + pass From d7485b3545274a8cf92e35ce3bc75ded3d26f4bf Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 9 Sep 2025 20:51:20 -0700 Subject: [PATCH 2/5] Update darts_test.py --- darts/darts_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darts/darts_test.py b/darts/darts_test.py index 0d0dbe0..b53333f 100644 --- a/darts/darts_test.py +++ b/darts/darts_test.py @@ -1,4 +1,4 @@ -# pylint: disable=C0301 +# pylint: disable=C0114, C0115, C0116, R0904 # These tests are auto-generated with test data from: # https://github.com/exercism/problem-specifications/tree/main/exercises/darts/canonical-data.json From 3a2ea5726cf6b561147033fe957584ef95196be4 Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 9 Sep 2025 21:16:34 -0700 Subject: [PATCH 3/5] Update darts.py --- darts/darts.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/darts/darts.py b/darts/darts.py index d65a3f7..f781798 100644 --- a/darts/darts.py +++ b/darts/darts.py @@ -1,5 +1,7 @@ """Darts is a game where players throw darts at a target.""" +from math import sqrt + def score(x: int, y: int) -> int: """ @@ -16,4 +18,12 @@ def score(x: int, y: int) -> int: :param y: The y-coordinate where the dart landed :return: The points scored (0, 1, 5, or 10) """ - pass + # Calculate distance form the center of the circle (0, 0) + distance: float = sqrt(pow(x, 2) + pow(y, 2)) + if distance > 10: + return 0 + if distance > 5: + return 1 + if distance > 1: + return 5 + return 10 From b7f41ac456030090ce68a3144e30cdb55f4c426b Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 9 Sep 2025 21:18:16 -0700 Subject: [PATCH 4/5] Update darts.py --- darts/darts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/darts/darts.py b/darts/darts.py index f781798..479a1b1 100644 --- a/darts/darts.py +++ b/darts/darts.py @@ -20,10 +20,14 @@ def score(x: int, y: int) -> int: """ # Calculate distance form the center of the circle (0, 0) distance: float = sqrt(pow(x, 2) + pow(y, 2)) + # Outside target if distance > 10: return 0 + # Outer circle if distance > 5: return 1 + # Middle circle if distance > 1: return 5 + # Inner circle return 10 From cb6ad026d400b1d2f6e2bdff87bafd041a943a54 Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 9 Sep 2025 21:19:20 -0700 Subject: [PATCH 5/5] Update darts.py --- darts/darts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darts/darts.py b/darts/darts.py index 479a1b1..b21cb4a 100644 --- a/darts/darts.py +++ b/darts/darts.py @@ -29,5 +29,5 @@ def score(x: int, y: int) -> int: # Middle circle if distance > 1: return 5 - # Inner circle + # Inner circle return 10