13-1.... ist Blödsinn
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.11 (AdventOfCode2023)" />
|
<option name="sdkName" value="Python 3.11 (AdventOfCode2023)" />
|
||||||
|
|||||||
16
13/13-1.py
16
13/13-1.py
@@ -3,7 +3,7 @@
|
|||||||
data = []
|
data = []
|
||||||
|
|
||||||
# parse input
|
# parse input
|
||||||
input_file = open("input-ex", "r")
|
input_file = open("input", "r")
|
||||||
pattern = []
|
pattern = []
|
||||||
for line in input_file:
|
for line in input_file:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
@@ -43,6 +43,7 @@ def find_vertikal_mirror(matrix):
|
|||||||
p1 = p1[::-1]
|
p1 = p1[::-1]
|
||||||
p1 = p1[:len(p2)]
|
p1 = p1[:len(p2)]
|
||||||
# print("2: ",s,p1,p2)
|
# print("2: ",s,p1,p2)
|
||||||
|
# print(p1,p2)
|
||||||
if p1 != p2:
|
if p1 != p2:
|
||||||
is_mirror = False
|
is_mirror = False
|
||||||
if is_mirror:
|
if is_mirror:
|
||||||
@@ -57,18 +58,23 @@ def find_horizontal_mirror(matrix):
|
|||||||
#for n in new_matrix:
|
#for n in new_matrix:
|
||||||
# print(n)
|
# print(n)
|
||||||
print("_____________________")
|
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
|
solution = 0
|
||||||
for m in data:
|
for m in data:
|
||||||
#print(m)
|
#print(m)
|
||||||
|
horz =0
|
||||||
for mn in m:
|
for mn in m:
|
||||||
print(mn)
|
print(mn)
|
||||||
vert = find_vertikal_mirror(m)
|
vert = find_vertikal_mirror(m)
|
||||||
horz = find_horizontal_mirror(m)
|
if vert == 0:
|
||||||
|
horz = find_horizontal_mirror(m)
|
||||||
print(vert, horz)
|
print(vert, horz)
|
||||||
solution += 100 * find_horizontal_mirror(m)
|
solution += 100 * horz
|
||||||
solution += vert
|
solution += vert
|
||||||
|
|
||||||
print("Lösung:", solution)
|
print("Lösung:", solution)
|
||||||
|
|||||||
Reference in New Issue
Block a user