Created
November 28, 2019 15:41
-
-
Save libdx/ed26ad80bb83c8b94fa6b502bac081bc 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
MAX = 50 | |
def solve(val: int, op: str) -> int: | |
if op == '+': | |
a = random.randint(0, val) | |
return val - a, a | |
elif op == '-': | |
a = random.randint(0, MAX - val) | |
return val + a, a | |
else: | |
raise ValueError(f'Wrong operation is provided: {op}') | |
def gen_example(n=1): | |
for _ in range(0, n): | |
val = random.randint(0, MAX) | |
op = '+' if random.randint(0, 1) == 1 else '-' | |
yield (val, op, *solve(val, op)) | |
[x for x in gen_example(5)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment