Compare commits

..

7 commits

2 changed files with 6 additions and 8 deletions

View file

@ -92,13 +92,12 @@ def solve(input: List[str]) -> int:
solver.add(registers["z"] == zero)
digits_to_num = lambda digits: functools.reduce(lambda a, b: a * 10 + b, digits)
model_number = functools.reduce(lambda a, b: a * 10 + b, digits)
solver.maximize(digits_to_num(digits))
solver.maximize(model_number)
assert solver.check() == z3.sat # Sanity check
model = solver.model()
return digits_to_num(model[d].as_long() for d in digits)
return solver.model().eval(model_number)
return run_z3(parse())

View file

@ -92,13 +92,12 @@ def solve(input: List[str]) -> int:
solver.add(registers["z"] == zero)
digits_to_num = lambda digits: functools.reduce(lambda a, b: a * 10 + b, digits)
model_number = functools.reduce(lambda a, b: a * 10 + b, digits)
solver.minimize(digits_to_num(digits))
solver.minimize(model_number)
assert solver.check() == z3.sat # Sanity check
model = solver.model()
return digits_to_num(model[d].as_long() for d in digits)
return solver.model().eval(model_number)
return run_z3(parse())