Created
December 24, 2021 06:19
-
-
Save bluepichu/95993aceb9457c079f3e2882f4ce5ef7 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 * | |
with open("input.txt") as f: | |
lines = f.readlines() | |
iters = [] | |
for i in range(14): | |
base = i * 18 | |
print(lines[base + 4], lines[base + 5], lines[base + 15]) | |
values = [ | |
int(lines[base + 4].split(" ")[2]), | |
int(lines[base + 5].split(" ")[2]), | |
int(lines[base + 15].split(" ")[2]), | |
] | |
iters.append(values) | |
print(iters) | |
digits = [Int("d{}".format(i)) for i in range(14)] | |
inp_count = 0 | |
z = 0 | |
for a, b, c in iters: | |
w = digits[inp_count] | |
x = (z % 26) + b | |
z /= a | |
z = If(x != w, 26 * z + w + c, z) | |
inp_count += 1 | |
s = Solver() | |
for d in digits: | |
s.add(d >= 1, d <= 9) | |
s.add(z == 0) | |
best = "" | |
while True: | |
if s.check() != sat: | |
break | |
out = s.model() | |
ans = "" | |
for i in range(14): | |
ans += str(out[digits[i]]) | |
best = ans | |
print(best) | |
s.add(sum([digits[i] * 10 ** (13 - i) for i in range(14)]) < int(ans)) | |
print(best) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment