Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
87aadb2
[Sync Iteration] python/hello-world/1
exercism-solutions-syncer[bot] Sep 12, 2025
04271b7
Merge pull request #1 from neginAhmadiTech/exercism-sync/643dd54accb2…
neginAhmadiTech Sep 12, 2025
722bb32
[Sync Iteration] python/guidos-gorgeous-lasagna/1
exercism-solutions-syncer[bot] Sep 12, 2025
516d961
[Sync Iteration] python/guidos-gorgeous-lasagna/2
exercism-solutions-syncer[bot] Sep 12, 2025
17f77c8
[Sync Iteration] python/guidos-gorgeous-lasagna/1
exercism-solutions-syncer[bot] Sep 12, 2025
339d9c6
[Sync Iteration] python/guidos-gorgeous-lasagna/2
exercism-solutions-syncer[bot] Sep 12, 2025
5fe9828
Merge pull request #2 from neginAhmadiTech/exercism-sync/015b254347d7…
neginAhmadiTech Sep 12, 2025
52350ea
Merge pull request #4 from neginAhmadiTech/exercism-sync/e026d34af5ca…
neginAhmadiTech Sep 12, 2025
06d9f65
Merge pull request #3 from neginAhmadiTech/exercism-sync/9560f4c0cb7a…
neginAhmadiTech Sep 12, 2025
5e1e432
[Sync Iteration] python/ghost-gobble-arcade-game/1
exercism-solutions-syncer[bot] Sep 12, 2025
c895e4c
[Sync Iteration] python/ghost-gobble-arcade-game/2
exercism-solutions-syncer[bot] Sep 12, 2025
325db0a
Merge pull request #5 from neginAhmadiTech/exercism-sync/079052383f8f…
neginAhmadiTech Sep 12, 2025
d292c0c
Iteration 2 of python/ghost-gobble-arcade-game merged
neginAhmadiTech Sep 12, 2025
0aa6fe6
Iteration 3 of python/ghost-gobble-arcade-game
exercism-solutions-syncer[bot] Sep 12, 2025
a4bbb70
[Sync Iteration] python/currency-exchange/1 (#8)
exercism-solutions-syncer[bot] Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions solutions/python/currency-exchange/1/exchange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""Functions for calculating steps in exchanging currency.

Python numbers documentation: https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex

Overview of exchanging currency when travelling: https://www.compareremit.com/money-transfer-tips/guide-to-exchanging-currency-for-overseas-travel/
"""



def exchange_money(budget, exchange_rate):
"""

:param budget: float - amount of money you are planning to exchange.
:param exchange_rate: float - unit value of the foreign currency.
:return: float - exchanged value of the foreign currency you can receive.
"""

return budget / exchange_rate


def get_change(budget, exchanging_value):
"""

:param budget: float - amount of money you own.
:param exchanging_value: float - amount of your money you want to exchange now.
:return: float - amount left of your starting currency after exchanging.
"""

return budget - exchanging_value


def get_value_of_bills(denomination, number_of_bills):
"""

:param denomination: int - the value of a bill.
:param number_of_bills: int - total number of bills.
:return: int - calculated value of the bills.
"""

return denomination * number_of_bills


def get_number_of_bills(amount, denomination):
"""

:param amount: float - the total starting value.
:param denomination: int - the value of a single bill.
:return: int - number of bills that can be obtained from the amount.
"""

return amount // denomination


def get_leftover_of_bills(amount, denomination):
"""

:param amount: float - the total starting value.
:param denomination: int - the value of a single bill.
:return: float - the amount that is "leftover", given the current denomination.
"""

return amount % denomination


def exchangeable_value(budget, exchange_rate, spread, denomination):
"""

:param budget: float - the amount of your money you are planning to exchange.
:param exchange_rate: float - the unit value of the foreign currency.
:param spread: int - percentage that is taken as an exchange fee.
:param denomination: int - the value of a single bill.
:return: int - maximum value you can get.
"""

spread_decimal = spread / 100
effective_rate = exchange_rate * (1 + spread_decimal)
exchanged_amount = budget / effective_rate
leftover = get_leftover_of_bills(exchanged_amount, denomination)
return int(exchanged_amount - leftover)
57 changes: 57 additions & 0 deletions solutions/python/ghost-gobble-arcade-game/1/arcade_game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Functions for implementing the rules of the classic arcade game Pac-Man."""


def eat_ghost(power_pellet_active, touching_ghost):
"""Verify that Pac-Man can eat a ghost if he is empowered by a power pellet.

:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - can a ghost be eaten?
"""

if power_pellet_active and touching_ghost:
return True
else:
return False

def score(touching_power_pellet, touching_dot):
"""Verify that Pac-Man has scored when a power pellet or dot has been eaten.

:param touching_power_pellet: bool - is the player touching a power pellet?
:param touching_dot: bool - is the player touching a dot?
:return: bool - has the player scored or not?
"""

if touching_power_pellet or touching_dot:
return True
else:
return False


def lose(power_pellet_active, touching_ghost):
"""Trigger the game loop to end (GAME OVER) when Pac-Man touches a ghost without his power pellet.

:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - has the player lost the game?
"""

if touching_ghost and (power_pellet_active == False):
return True
else:
return False


def win(has_eaten_all_dots, power_pellet_active, touching_ghost):
"""Trigger the victory event when all dots have been eaten.

:param has_eaten_all_dots: bool - has the player "eaten" all the dots?
:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - has the player won the game?
"""

if has_eaten_all_dots and (lose(power_pellet_active, touching_ghost) == False):
return True
else:
return False
44 changes: 44 additions & 0 deletions solutions/python/ghost-gobble-arcade-game/2/arcade_game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""Functions for implementing the rules of the classic arcade game Pac-Man."""


def eat_ghost(power_pellet_active, touching_ghost):
"""Verify that Pac-Man can eat a ghost if he is empowered by a power pellet.

:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - can a ghost be eaten?
"""

return power_pellet_active and touching_ghost

def score(touching_power_pellet, touching_dot):
"""Verify that Pac-Man has scored when a power pellet or dot has been eaten.

:param touching_power_pellet: bool - is the player touching a power pellet?
:param touching_dot: bool - is the player touching a dot?
:return: bool - has the player scored or not?
"""

return touching_power_pellet or touching_dot


def lose(power_pellet_active, touching_ghost):
"""Trigger the game loop to end (GAME OVER) when Pac-Man touches a ghost without his power pellet.

:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - has the player lost the game?
"""

return touching_ghost and (power_pellet_active == False)

def win(has_eaten_all_dots, power_pellet_active, touching_ghost):
"""Trigger the victory event when all dots have been eaten.

:param has_eaten_all_dots: bool - has the player "eaten" all the dots?
:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - has the player won the game?
"""

return has_eaten_all_dots and (lose(power_pellet_active, touching_ghost) == False)
44 changes: 44 additions & 0 deletions solutions/python/ghost-gobble-arcade-game/3/arcade_game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""Functions for implementing the rules of the classic arcade game Pac-Man."""


def eat_ghost(power_pellet_active, touching_ghost):
"""Verify that Pac-Man can eat a ghost if he is empowered by a power pellet.

:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - can a ghost be eaten?
"""

return power_pellet_active and touching_ghost

def score(touching_power_pellet, touching_dot):
"""Verify that Pac-Man has scored when a power pellet or dot has been eaten.

:param touching_power_pellet: bool - is the player touching a power pellet?
:param touching_dot: bool - is the player touching a dot?
:return: bool - has the player scored or not?
"""

return touching_power_pellet or touching_dot


def lose(power_pellet_active, touching_ghost):
"""Trigger the game loop to end (GAME OVER) when Pac-Man touches a ghost without his power pellet.

:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - has the player lost the game?
"""

return touching_ghost and (power_pellet_active is False)

def win(has_eaten_all_dots, power_pellet_active, touching_ghost):
"""Trigger the victory event when all dots have been eaten.

:param has_eaten_all_dots: bool - has the player "eaten" all the dots?
:param power_pellet_active: bool - does the player have an active power pellet?
:param touching_ghost: bool - is the player touching a ghost?
:return: bool - has the player won the game?
"""

return has_eaten_all_dots and (lose(power_pellet_active, touching_ghost) is False)
52 changes: 52 additions & 0 deletions solutions/python/guidos-gorgeous-lasagna/1/lasagna.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Functions used in preparing Guido's gorgeous lasagna.

Learn about Guido, the creator of the Python language:
https://en.wikipedia.org/wiki/Guido_van_Rossum

This is a module docstring, used to describe the functionality
of a module and its functions and/or classes.
"""

EXPECTED_BAKE_TIME = 40
PREPARATION_TIME = 2


def bake_time_remaining(elapsed_bake_time):
"""Calculate the bake time remaining.

:param elapsed_bake_time: int - baking time already elapsed.
:return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.

Function that takes the actual minutes the lasagna has been in the oven as
an argument and returns how many minutes the lasagna still needs to bake
based on the `EXPECTED_BAKE_TIME`.
"""
return EXPECTED_BAKE_TIME - elapsed_bake_time

def preparation_time_in_minutes(number_of_layers):
"""Calculate the preperation time based on layers.

:param number_of_layers: int - the number of layers.
:return: int - the preperation time it takes in minutes based on number of layers and PREPARATION_TIME.

Function that takes the number of layers we want to add to the lasagna and returns how many minutes we would spend making them.
"""

return number_of_layers * PREPARATION_TIME

def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):

"""Calculate the elapsed cooking time.

:param number_of_layers: int - the number of layers in the lasagna.
:param elapsed_bake_time: int - elapsed cooking time.
:return: int - total time elapsed (in minutes) preparing and cooking.

This function takes two integers representing the number of lasagna layers and the
time already spent baking and calculates the total elapsed minutes spent cooking the
lasagna.
"""

return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time


50 changes: 50 additions & 0 deletions solutions/python/guidos-gorgeous-lasagna/2/lasagna.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Functions used in preparing Guido's gorgeous lasagna.

Learn about Guido, the creator of the Python language:
https://en.wikipedia.org/wiki/Guido_van_Rossum

This is a module docstring, used to describe the functionality
of a module and its functions and/or classes.
"""

EXPECTED_BAKE_TIME = 40
PREPARATION_TIME = 2


def bake_time_remaining(elapsed_bake_time):
"""Calculate the bake time remaining.

:param elapsed_bake_time: int - baking time already elapsed.
:return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.

Function that takes the actual minutes the lasagna has been in the oven as
an argument and returns how many minutes the lasagna still needs to bake
based on the `EXPECTED_BAKE_TIME`.
"""
return EXPECTED_BAKE_TIME - elapsed_bake_time

def preparation_time_in_minutes(number_of_layers):
"""Calculate the preperation time based on layers.

:param number_of_layers: int - the number of layers.
:return: int - the preperation time it takes in minutes based on number of layers and PREPARATION_TIME.

Function that takes the number of layers we want to add to the lasagna and returns how many minutes we would spend making them.
"""

return number_of_layers * PREPARATION_TIME

def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):

"""Calculate the elapsed cooking time.

:param number_of_layers: int - the number of layers in the lasagna.
:param elapsed_bake_time: int - elapsed cooking time.
:return: int - total time elapsed (in minutes) preparing and cooking.

This function takes two integers representing the number of lasagna layers and the
time already spent baking and calculates the total elapsed minutes spent cooking the
lasagna.
"""

return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time
2 changes: 2 additions & 0 deletions solutions/python/hello-world/1/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello():
return "Hello, World!"