day 3-1
This commit is contained in:
27
03/03-1.py
Normal file
27
03/03-1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#file = "./ex.txt"
|
||||
file = "./input.txt"
|
||||
|
||||
def find_num(l:str) -> int:
|
||||
numbers = "9876543210"
|
||||
for z1 in numbers:
|
||||
if z1 in l[:-1]:
|
||||
start_pos = l.find(z1)+1
|
||||
for z2 in numbers:
|
||||
if z2 in l[start_pos:]:
|
||||
print(f"{z1}{z2}")
|
||||
return int(f"{z1}{z2}")
|
||||
return -999999999
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
solution = 0
|
||||
input_file = open(file, "r")
|
||||
for line in input_file:
|
||||
line = line.strip()
|
||||
if line == "":
|
||||
continue
|
||||
solution += find_num(line)
|
||||
print(f"Solution: {solution}")
|
||||
Reference in New Issue
Block a user