Created
February 5, 2020 05:37
-
-
Save shinh/093ebf7e63aadf96b33e5a3e973d6124 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
from z3 import * | |
x, y, a = Ints(['x', 'y', 'a']) | |
solver = Solver() | |
def r(x, n): | |
solver.add(x >= n) | |
solver.add(x < n * 10) | |
solver.add(y * 10 == x * a) | |
solver.add(((x % 10) * (a % 10)) % 10 == 0) | |
solver.add(((x % 10) * (a / 100)) % 10 == 6) | |
r(x, 10) | |
r(y, 1000) | |
r(a, 100) | |
r(x * (a / 100), 100) | |
r(x * (a / 10 % 10), 10) | |
r(x * (a % 10), 10) | |
r(y / 10 - x * (a / 100), 10) | |
r = solver.check() | |
if r == sat: | |
m = solver.model() | |
print(m[x], m[y], m[a]) | |
else: | |
print('unsat') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment