Last active
March 1, 2022 00:04
-
-
Save maxfire2008/876bc39f5dbc2722b9920c2a435e033c to your computer and use it in GitHub Desktop.
Brute forces a math sum with multiple blanks
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
import itertools | |
side_a = "(a+b)/c==d" | |
v = [-9,-2,8,-7] | |
for p in itertools.permutations(v,len(v)): | |
side_a_m = side_a | |
for i,v in enumerate(p): | |
side_a_m=side_a_m.replace(chr(i+97),"("+str(v)+")") | |
if eval(side_a_m): | |
print(side_a_m,eval(side_a_m)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment