Files
advent-of-code/2025/day03/part1.py

34 lines
1.2 KiB
Python

# input = """987654321111111
# 811111111111119
# 234234234234278
# 818181911112111
# """
# input = "5767884946576766546558768767844146766387555466875566737775468663634866855528868858567496986549486867"
result = 0
with open("input.txt", "r") as file:
input = file.read()
# читаем ввод построчно и возращает block
for block in input.splitlines():
# проверяем что в строке.
for i in range(9, 0, -1):
# print("i -",i)
if block.count(str(i)) >= 1:
if block.find(str(i)) + 1 == len(block):
pass
else:
if block.count(str(i)) >= 2:
split = block.rindex(str(i),0,block.rindex(str(i))) +1
# print(split)
else:
split = block.rindex(str(i)) +1
ii = block[split:]
# print(ii)
for y in range(9, 0, -1):
# print("y -",y)
if ii.count(str(y)) >= 1:
print(f"in block {block},bestcombo is {i}{y}")
result += int(str(i) + str(y))
break
break
print(f"result - {result}")