Skip to content

Instantly share code, notes, and snippets.

@maxfire2008
Last active March 1, 2022 00:04
Show Gist options
  • Save maxfire2008/876bc39f5dbc2722b9920c2a435e033c to your computer and use it in GitHub Desktop.
Save maxfire2008/876bc39f5dbc2722b9920c2a435e033c to your computer and use it in GitHub Desktop.
Brute forces a math sum with multiple blanks
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