13-1.... ist Blödsinn

This commit is contained in:
2023-12-13 20:34:08 +01:00
parent 6a2336c02a
commit c9e9eb6c61
2 changed files with 11 additions and 6 deletions

1
.idea/misc.xml generated
View File

@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (AdventOfCode2023)" />

View File

@@ -3,7 +3,7 @@
data = []
# parse input
input_file = open("input-ex", "r")
input_file = open("input", "r")
pattern = []
for line in input_file:
line = line.strip()
@@ -43,6 +43,7 @@ def find_vertikal_mirror(matrix):
p1 = p1[::-1]
p1 = p1[:len(p2)]
# print("2: ",s,p1,p2)
# print(p1,p2)
if p1 != p2:
is_mirror = False
if is_mirror:
@@ -57,18 +58,23 @@ def find_horizontal_mirror(matrix):
#for n in new_matrix:
# print(n)
print("_____________________")
return find_vertikal_mirror(new_matrix)
t = find_vertikal_mirror(new_matrix)
if t<=len(matrix[0])/2:
return t+1
else:
return t
solution = 0
for m in data:
#print(m)
horz =0
for mn in m:
print(mn)
vert = find_vertikal_mirror(m)
horz = find_horizontal_mirror(m)
if vert == 0:
horz = find_horizontal_mirror(m)
print(vert, horz)
solution += 100 * find_horizontal_mirror(m)
solution += 100 * horz
solution += vert
print("Lösung:", solution)