Created
April 16, 2023 15:59
-
-
Save audhiaprilliant/4930c5670a4baf5f34c7d2af9731d1d6 to your computer and use it in GitHub Desktop.
Creating a Monopoly Game Board Simulation with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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