This commit is contained in:
2024-12-18 21:49:29 +01:00
parent 148a1426c7
commit 96293aa9e8
3 changed files with 1799 additions and 0 deletions

37
03/03-2.py Normal file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
file = "./input.txt"
from time import time
start_time = time()
def check_triple(triple:list[int])->bool:
triple=sorted(triple)
if triple[0]+triple[1] > triple[2]:
return True
else:
return False
def read_input(filename:str)->list[list[int]]:
out = []
input_file = open(filename, "r")
for line in input_file:
line = line.strip()
if line == "":
continue
else:
out.append(list(map(int,line.split())))
input_file.close()
return out
if __name__ == "__main__":
sol = 0
data = read_input(file)
for l in range(0,len(data),3):
for r in range(3):
if check_triple([data[l][r],data[l+1][r],data[l+2][r]]):
sol += 1
print(f"Solution - Part2: {sol}")
print(f'Runtime: {time()-start_time:.4f} s')