46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
from lib import get_data
|
|
|
|
data = get_data(__file__)
|
|
|
|
|
|
def run(number):
|
|
inputs = list(map(int, str(number)))
|
|
assert len(inputs) == 14
|
|
|
|
w, x, z = 0, 0, 0
|
|
i = 0
|
|
for i in range(len(inputs)):
|
|
w = inputs[i]
|
|
# print(f"{w=:3} {x=:3} {z=}")
|
|
|
|
to_add_x = [15, 15, 12, 13, -12, 10, -9, 14, 13, -14, -11, -2, -16, -14][i]
|
|
to_div_z = [1, 1, 1, 1, 26, 1, 26, 1, 1, 26, 26, 26, 26, 26][i]
|
|
to_add_z = [15, 10, 2, 16, 12, 11, 5, 16, 6, 15, 3, 12, 10, 13][i]
|
|
|
|
zz = z
|
|
x = (z % 26) + to_add_x
|
|
z = z // to_div_z
|
|
|
|
# print(f"{zz % 26=} + {to_add_x=} {x=}")
|
|
|
|
if x == w:
|
|
# print(f"added = 0")
|
|
pass
|
|
else:
|
|
z *= 26
|
|
z += w + to_add_z
|
|
# print(f"added {w=} + {to_add_z=} = {w + to_add_z}")
|
|
# print()
|
|
|
|
# print(f"\nEND:\n{w=} {x=} {z=}", "\n" * 15)
|
|
return z
|
|
|
|
|
|
largest_model_nr = 89959794919939
|
|
assert run(largest_model_nr) == 0
|
|
print(largest_model_nr)
|
|
|
|
lowest_model_nr = 17115131916112
|
|
assert run(lowest_model_nr) == 0
|
|
print(lowest_model_nr)
|