Skip to content

Instantly share code, notes, and snippets.

@audhiaprilliant
Created April 16, 2023 15:59
Show Gist options
  • Save audhiaprilliant/4930c5670a4baf5f34c7d2af9731d1d6 to your computer and use it in GitHub Desktop.
Save audhiaprilliant/4930c5670a4baf5f34c7d2af9731d1d6 to your computer and use it in GitHub Desktop.
Creating a Monopoly Game Board Simulation with Python
# Find the shortest spaces in circular list
def distance_space(
data_space: dict,
first_index: int,
second_index: int
):
# Update the data space
data_space_update = (data_space[first_index - 1:] + data_space[:first_index - 1])
# Calculate the distance
distance = next((index for (index, dict_) in enumerate(data_space_update) if dict_['order'] == second_index), None)
return distance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment