1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-11-08 13:39:53 +00:00
random-stuff/collatzz3.py

17 lines
340 B
Python
Raw Normal View History

2021-03-21 19:36:03 +00:00
from z3 import *
iters = [ Int(f"x{i}") for i in range(20) ]
solver = Solver()
for n,x in enumerate(iters):
if n == 0:
solver.add(x == 1111)
else:
last = iters[n - 1]
solver.add(Or(x == last, (x * 2) == last, x == ((last * 3) + 1)))
solver.add(iters[-1] == 1)
print(solver.check())
print(solver.model())