13-1 grrr2
This commit is contained in:
22
13/13-1.py
22
13/13-1.py
@@ -21,22 +21,28 @@ for i in range(len(data)):
|
|||||||
print("================")
|
print("================")
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def find_vertikal_mirror(matrix):
|
def find_vertikal_mirror(matrix):
|
||||||
|
#print(type(matrix), matrix)
|
||||||
|
#print(type(matrix[0]), matrix[0], len(matrix[0]))
|
||||||
for s in range(1, len(matrix[0])):
|
for s in range(1, len(matrix[0])):
|
||||||
|
#print((len(matrix[0])))
|
||||||
is_mirror = True
|
is_mirror = True
|
||||||
for z in matrix:
|
for z in matrix:
|
||||||
|
#print("z",z)
|
||||||
if s <= len(z) / 2:
|
if s <= len(z) / 2:
|
||||||
p1 = z[:s]
|
p1 = z[:s]
|
||||||
p2 = z[s:]
|
p2 = z[s:]
|
||||||
p2 = p2[::-1]
|
|
||||||
p2 = p2[:s]
|
p2 = p2[:s]
|
||||||
print("1: ",s,p1,"-",p2)
|
p2 = p2[::-1]
|
||||||
|
|
||||||
|
# print("1: ",s,p1,"__",p2)
|
||||||
else:
|
else:
|
||||||
p2 = z[s:]
|
p2 = z[s:]
|
||||||
p1 = z[:s]
|
p1 = z[:s]
|
||||||
p1 = p1[::-1]
|
p1 = p1[::-1]
|
||||||
p1 = p1[:len(p2)]
|
p1 = p1[:len(p2)]
|
||||||
print("2: ",s,p1,p2)
|
# print("2: ",s,p1,p2)
|
||||||
if p1 != p2:
|
if p1 != p2:
|
||||||
is_mirror = False
|
is_mirror = False
|
||||||
if is_mirror:
|
if is_mirror:
|
||||||
@@ -47,24 +53,22 @@ def find_vertikal_mirror(matrix):
|
|||||||
def find_horizontal_mirror(matrix):
|
def find_horizontal_mirror(matrix):
|
||||||
new_matrix = []
|
new_matrix = []
|
||||||
for j in range(len(matrix[0])):
|
for j in range(len(matrix[0])):
|
||||||
new_matrix.append("".join([matrix[k][j] for k in range(len(matrix))]))
|
new_matrix.append("".join([matrix[k][j] for k in range(len(matrix)-1,-1,-1)]))
|
||||||
for n in new_matrix:
|
#for n in new_matrix:
|
||||||
print(n)
|
# print(n)
|
||||||
print("_____________________")
|
print("_____________________")
|
||||||
return find_vertikal_mirror(new_matrix)
|
return find_vertikal_mirror(new_matrix)
|
||||||
|
|
||||||
|
|
||||||
solution = 0
|
solution = 0
|
||||||
for m in data:
|
for m in data:
|
||||||
print(m)
|
#print(m)
|
||||||
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)
|
horz = find_horizontal_mirror(m)
|
||||||
print(vert, horz)
|
print(vert, horz)
|
||||||
if vert == 0:
|
|
||||||
solution += 100 * find_horizontal_mirror(m)
|
solution += 100 * find_horizontal_mirror(m)
|
||||||
else:
|
|
||||||
solution += vert
|
solution += vert
|
||||||
|
|
||||||
print("Lösung:", solution)
|
print("Lösung:", solution)
|
||||||
|
|||||||
33
13/input-ex
33
13/input-ex
@@ -13,36 +13,3 @@
|
|||||||
#####.##.
|
#####.##.
|
||||||
..##..###
|
..##..###
|
||||||
#....#..#
|
#....#..#
|
||||||
|
|
||||||
#..######.#....
|
|
||||||
####....#..##.#
|
|
||||||
####....#..##.#
|
|
||||||
#..######.#....
|
|
||||||
.#...#####..#..
|
|
||||||
#...####...#.#.
|
|
||||||
##...#.#...#..#
|
|
||||||
.##.##.#.....#.
|
|
||||||
..#..##....##..
|
|
||||||
..#.....#..##.#
|
|
||||||
##...#...#####.
|
|
||||||
##...#...#####.
|
|
||||||
..#..#..#..##.#
|
|
||||||
|
|
||||||
####.##...##.
|
|
||||||
.##.#.##..##.
|
|
||||||
.##....###..#
|
|
||||||
####.........
|
|
||||||
#..#.#.#.....
|
|
||||||
#..######.###
|
|
||||||
#..###..#....
|
|
||||||
#..#####.....
|
|
||||||
#####....#..#
|
|
||||||
....#.....##.
|
|
||||||
#..#......##.
|
|
||||||
.##..##.#####
|
|
||||||
.##.#...#####
|
|
||||||
.....#.#..##.
|
|
||||||
.##...#..#..#
|
|
||||||
|
|
||||||
AA--AA--AA
|
|
||||||
AB-CDDC-BA
|
|
||||||
|
|||||||
Reference in New Issue
Block a user