Created
January 27, 2024 18:02
-
-
Save kleutzinger/97416454095dcfe23dcc91b383bd9ba0 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
how many valid answers are there on this "Math Spinner?" | |
https://i.imgur.com/HYiaxUN.jpeg | |
""" | |
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
operators = "+-*" | |
# find all valid | |
tot = 0 | |
valid = 0 | |
for left in nums: | |
for mid in nums: | |
for a in nums: | |
for b in nums: | |
for op in operators: | |
right = int(f"{a}{b}") | |
calc = f"{left}{op}{mid}=={right}" | |
if eval(calc): | |
print(calc) | |
valid += 1 | |
tot += 1 | |
print(f"Valid: {valid}") | |
print(f"Total: {tot}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment