first commit
This commit is contained in:
34
2025/day03/part1.py
Normal file
34
2025/day03/part1.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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}")
|
||||
Reference in New Issue
Block a user