From 4a3b86a3a8146f32f7a3e2012c0b647f905d7aa3 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 04:06:35 +0000 Subject: [PATCH 1/7] [Sync Iteration] python/ellens-alien-game/1 --- .../python/ellens-alien-game/1/classes.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 solutions/python/ellens-alien-game/1/classes.py diff --git a/solutions/python/ellens-alien-game/1/classes.py b/solutions/python/ellens-alien-game/1/classes.py new file mode 100644 index 0000000..aaf775c --- /dev/null +++ b/solutions/python/ellens-alien-game/1/classes.py @@ -0,0 +1,55 @@ +"""Solution to Ellen's Alien Game exercise.""" + + +class Alien: + """ + Create an Alien object with location x_coordinate and y_coordinate. + + Attributes + ---------- + (class) + total_aliens_created: int + x_coordinate: int - Position on the x-axis. + y_coordinate: int - Position on the y-axis. + health: int - Number of health points. + + Methods + ------- + hit(): Decrement Alien health by one point. + is_alive(): Return a boolean for if Alien is alive (if health is > 0). + teleport(new_x_coordinate, new_y_coordinate): Move Alien object to new coordinates. + collision_detection(other): Implementation TBD. + """ + + total_aliens_created: int = 0 + + def __init__(self, x_coordinate: int, y_coordinate: int): + self.health: int = 3 + self.x_coordinate = x_coordinate + self.y_coordinate = y_coordinate + Alien.total_aliens_created += 1 + + def is_alive(self): + return self.health > 0 + + def hit(self): + self.health -= 1 + + def teleport(self, new_x_coordinate, new_y_coordinate): + self.x_coordinate = new_x_coordinate + self.y_coordinate = new_y_coordinate + + def collision_detection(self, other): + pass + + +def new_aliens_collection( + alien_start_positions: list[tuple[int, int]], +) -> list: + """ + Creates a list of Alien() objects, given a list of positions (as tuples). + + :param alien_start_positions: given a list of positions + :return: a list of Alien() objects + """ + return list(Alien(pos[0], pos[1]) for pos in alien_start_positions) From 4e47bb3bb2ddccd09e401ef47451e13902a452a5 Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 14 Oct 2025 21:21:16 -0700 Subject: [PATCH 2/7] Update classes.py --- ellens-alien-game/classes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ellens-alien-game/classes.py b/ellens-alien-game/classes.py index aaf775c..7c94904 100644 --- a/ellens-alien-game/classes.py +++ b/ellens-alien-game/classes.py @@ -3,7 +3,7 @@ class Alien: """ - Create an Alien object with location x_coordinate and y_coordinate. + Alien located at given coordinates. Attributes ---------- @@ -17,7 +17,8 @@ class Alien: ------- hit(): Decrement Alien health by one point. is_alive(): Return a boolean for if Alien is alive (if health is > 0). - teleport(new_x_coordinate, new_y_coordinate): Move Alien object to new coordinates. + teleport(new_x_coordinate, new_y_coordinate): Move Alien object + to new coordinates. collision_detection(other): Implementation TBD. """ @@ -47,7 +48,7 @@ def new_aliens_collection( alien_start_positions: list[tuple[int, int]], ) -> list: """ - Creates a list of Alien() objects, given a list of positions (as tuples). + Create a list of Alien objects from starting positions. :param alien_start_positions: given a list of positions :return: a list of Alien() objects From b647448127c682bf09e852bb74694b6a792d9347 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 04:26:07 +0000 Subject: [PATCH 3/7] [Sync Iteration] python/ellens-alien-game/2 --- .../python/ellens-alien-game/2/classes.py | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 solutions/python/ellens-alien-game/2/classes.py diff --git a/solutions/python/ellens-alien-game/2/classes.py b/solutions/python/ellens-alien-game/2/classes.py new file mode 100644 index 0000000..0c0ac3a --- /dev/null +++ b/solutions/python/ellens-alien-game/2/classes.py @@ -0,0 +1,92 @@ +"""Solution to Ellen's Alien Game exercise.""" + + +class Alien: + """ + Alien located at given coordinates. + + Attributes + ---------- + (class) + total_aliens_created: int + x_coordinate: int - Position on the x-axis. + y_coordinate: int - Position on the y-axis. + health: int - Number of health points. + + Methods + ------- + hit(): Decrement Alien health by one point. + is_alive(): Return a boolean for if Alien is alive (if health is > 0). + teleport(new_x_coordinate, new_y_coordinate): Move Alien object + to new coordinates. + collision_detection(other): Implementation TBD. + """ + + total_aliens_created: int = 0 + + def __init__(self, x_coordinate: int, y_coordinate: int): + """ + Initialize a new Alien at the provided coordinates. + + Sets health to 3, assigns x and y coordinates, and increments + Alien.total_aliens_created. + + :param x_coordinate: Position on the x-axis. + :param y_coordinate: Position on the y-axis. + :return: None + """ + self.health: int = 3 + self.x_coordinate = x_coordinate + self.y_coordinate = y_coordinate + Alien.total_aliens_created += 1 + + def is_alive(self): + """ + Return whether the alien is alive. + + :return: True if health > 0, else False. + """ + return self.health > 0 + + def hit(self): + """ + Decrement the alien's health by one point. + + :return: None + """ + self.health -= 1 + + def teleport(self, new_x_coordinate, new_y_coordinate): + """ + Decrement the alien's health by one point. + + :return: None + """ + self.x_coordinate = new_x_coordinate + self.y_coordinate = new_y_coordinate + + def collision_detection(self, other): + """ + Determine whether this Alien collides with another. + + Implementation TBD; currently returns None. + + :param other: Another Alien or object to check for + positional overlap. + :return: None + + `Source: /ellens-alien-game/classes_test.py` + """ + pass + + +def new_aliens_collection( + alien_start_positions: list[tuple[int, int]], +) -> list: + """ + Create a list of Alien objects from starting positions. + + :param alien_start_positions: given a list of positions + :return: a list of Alien() objects + """ + return list(Alien(pos[0], pos[1]) for pos in alien_start_positions) From 8fabdb0cc2db0b7de684beaef623d559e218f204 Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 14 Oct 2025 21:26:08 -0700 Subject: [PATCH 4/7] Update classes.py --- ellens-alien-game/classes.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ellens-alien-game/classes.py b/ellens-alien-game/classes.py index 7c94904..0c0ac3a 100644 --- a/ellens-alien-game/classes.py +++ b/ellens-alien-game/classes.py @@ -25,22 +25,58 @@ class Alien: total_aliens_created: int = 0 def __init__(self, x_coordinate: int, y_coordinate: int): + """ + Initialize a new Alien at the provided coordinates. + + Sets health to 3, assigns x and y coordinates, and increments + Alien.total_aliens_created. + + :param x_coordinate: Position on the x-axis. + :param y_coordinate: Position on the y-axis. + :return: None + """ self.health: int = 3 self.x_coordinate = x_coordinate self.y_coordinate = y_coordinate Alien.total_aliens_created += 1 def is_alive(self): + """ + Return whether the alien is alive. + + :return: True if health > 0, else False. + """ return self.health > 0 def hit(self): + """ + Decrement the alien's health by one point. + + :return: None + """ self.health -= 1 def teleport(self, new_x_coordinate, new_y_coordinate): + """ + Decrement the alien's health by one point. + + :return: None + """ self.x_coordinate = new_x_coordinate self.y_coordinate = new_y_coordinate def collision_detection(self, other): + """ + Determine whether this Alien collides with another. + + Implementation TBD; currently returns None. + + :param other: Another Alien or object to check for + positional overlap. + :return: None + + `Source: /ellens-alien-game/classes_test.py` + """ pass From 2939821bac5ac87e8c6941422d5bc9180ef7d8ed Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 14 Oct 2025 21:29:52 -0700 Subject: [PATCH 5/7] Update classes.py --- ellens-alien-game/classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ellens-alien-game/classes.py b/ellens-alien-game/classes.py index 0c0ac3a..78287f5 100644 --- a/ellens-alien-game/classes.py +++ b/ellens-alien-game/classes.py @@ -77,7 +77,7 @@ def collision_detection(self, other): `Source: /ellens-alien-game/classes_test.py` """ - pass + return None def new_aliens_collection( From b80a02988931cb02860011da554cf142684b693c Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 14 Oct 2025 21:33:31 -0700 Subject: [PATCH 6/7] Update classes.py --- ellens-alien-game/classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ellens-alien-game/classes.py b/ellens-alien-game/classes.py index 78287f5..0c0ac3a 100644 --- a/ellens-alien-game/classes.py +++ b/ellens-alien-game/classes.py @@ -77,7 +77,7 @@ def collision_detection(self, other): `Source: /ellens-alien-game/classes_test.py` """ - return None + pass def new_aliens_collection( From 9708046fdaffefcdda68964e33fdeb38cde00025 Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 14 Oct 2025 21:37:26 -0700 Subject: [PATCH 7/7] Update classes.py --- ellens-alien-game/classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ellens-alien-game/classes.py b/ellens-alien-game/classes.py index 0c0ac3a..c66684e 100644 --- a/ellens-alien-game/classes.py +++ b/ellens-alien-game/classes.py @@ -77,7 +77,7 @@ def collision_detection(self, other): `Source: /ellens-alien-game/classes_test.py` """ - pass + pass # pylint: disable=unnecessary-pass def new_aliens_collection(