Skip to content

Instantly share code, notes, and snippets.

@sat0b
Created May 21, 2017 16:48
Show Gist options
  • Select an option

  • Save sat0b/5a3422751d84a094e4eeabaedb82377a to your computer and use it in GitHub Desktop.

Select an option

Save sat0b/5a3422751d84a094e4eeabaedb82377a to your computer and use it in GitHub Desktop.
import sys
def main(eq):
eq = eq.replace("=", "==")
for i in range(0, 10):
try:
if eval(eq.replace("X", str(i))):
print("X=%d" % i)
return
except SyntaxError:
pass
print("X=none")
main(sys.argv[1])
#!/bin/bash
set -eu
echo "Input : 123+4X6=X79, Answer : X=5"
python hukumen.py "123+4X6=X79"
echo "Input : XX22+89=X2XX, Answer : X=1"
python hukumen.py "XX22+89=X2XX"
echo "Input : 12X+4X6=X79, Answer : X=none"
python hukumen.py "12X+4X6=X79"
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment