Skip to content

Instantly share code, notes, and snippets.

@Trafitto
Created May 28, 2023 09:40
Show Gist options
  • Save Trafitto/b0c2dcafb612bad82ed74135e4379c81 to your computer and use it in GitHub Desktop.
Save Trafitto/b0c2dcafb612bad82ed74135e4379c81 to your computer and use it in GitHub Desktop.
Not the end tools
import random
def simulate(num_tokens_to_pick, black_tokens, white_tokens):
picked_tokens = []
for _ in range(min(num_tokens_to_pick, black_tokens)):
picked_tokens.append("black")
black_tokens -= 1
num_tokens_to_pick -= 1
for _ in range(min(num_tokens_to_pick, white_tokens)):
picked_tokens.append("white")
white_tokens -= 1
num_tokens_to_pick -= 1
random.shuffle(picked_tokens)
return picked_tokens
black_tokens = int(input("How black token you put in that bag?"))
white_tokens = int(input("How white token you put in that bag?"))
num_tokens_to_pick = int(input("How many time you want to pick? "))
print(simulate(num_tokens_to_pick, black_tokens, white_tokens))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment