11-1 fertig

This commit is contained in:
2023-12-11 16:03:39 +01:00
parent 2f3dd824d0
commit 25175daff9
8 changed files with 350 additions and 3 deletions

57
11/11-1.py Normal file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
data = []
# read matrix like day 3
input_file = open("input", "r")
for line in input_file:
line = line.strip()
data.append(line)
if line.count(".") == len(line): # Zeilen ohne # gleich verdoppeln
data.append(line)
input_file.close()
zeilen = len(data)
spalten = len(data[0])
# zum test mal ausgeben
for da in data:
print(da)
print(zeilen, spalten)
# leere Spalten ermitteln
freie_spalten = [1 for i in range(spalten)]
for da in data:
for i in range(spalten):
if da[i] == "#":
freie_spalten[i] = 0
print(freie_spalten)
# Spalten verbreitern
new_data = []
for da in data:
for i in range(len(freie_spalten)-1, -1, -1):
if freie_spalten[i] == 1:
da = da[:i] + ".." + da[i+1:]
new_data.append(da)
# Testausgabe neue Matrix
for da in new_data:
print(da)
zeilen = len(new_data)
spalten = len(new_data[0])
print(zeilen, spalten)
koor_list = []
for z in range(len(new_data)):
for s in range(len(new_data[0])):
if new_data[z][s] == "#":
koor_list.append([z, s])
print(koor_list)
summe = 0
for k in range(len(koor_list)):
for m in range(k+1, len(koor_list)):
summe += abs(koor_list[m][0] - koor_list[k][0])
summe += abs(koor_list[m][1] - koor_list[k][1])
print(summe)

140
11/input Normal file
View File

@@ -0,0 +1,140 @@
......................................#.....................................#......#.......#.....................#.................#........
............................................................................................................................................
.............................................#............................................................................................#.
..........................#..................................#........#............................#........................................
...#...........................#.................#............................................#...............................#.............
....................#.................................#..................................................#.........#........................
......................................#...............................................................................................#.....
...................................................................................#.............#..........................................
.......................#.........................................#......................#..................................#.....#..........
...............#................#...................#.........................#.................................#...........................
.......#..............................................................#.....................................................................
........................................#...................#.............................................#.................................
...........................#.....................#..................................................#..................#....................
.................#........................................................................#.......................#.........................
............#..................................................#...............................#........................................#...
.#................................#.........................................................................#...............................
.....................................................#...............#....................................................#.................
..........................#...................#....................................#.................#.........................#............
........#..............................#............................................................................#.......................
........................................................#................#..................................................................
...................#.............#...............................#.........................................#................................
........................#...........................#.........................#......#.....................................................#
..#........#.................#....................................................................................................#.........
.............................................#.............#.........................................#............#.........................
...............#......................................................#......................#..........................................#...
............................................................................................................................................
..................................................................................#........................................#................
..........................#........#......#..............#.....#................................................................#...........
.........................................................................................#.....#..............#.............................
....................#..........#.....................#................................................................................#.....
.#....................................................................#........#...........................................................#
..........#..............................................................................................................#..................
............................................................#......................................#........................................
...............#..........#................................................................................#................................
........................................................#..................................#.....................................#..........
......................#................#...............................................................................................#....
........#.......................................#.........................................................................#.................
.........................................................................#........#..................................#......................
#..................................#......#............................................................#...........................#........
............................................................................................................................................
......#.................................................#..............................#....................................................
.........................#....................................................#..............................................#..........#...
.................................#.............................................................................#............................
.................#..................................#................#...........................#..........................................
..............................................................#......................#......#...............................................
.............#..........................#.................................................................................................#.
...............................#........................#...................................................................................
....................................#.................................................................#..............#......................
.......#....................................................................#.................#................................#............
..........................#.................#.....#.................#....................................................#.............#....
............................................................................................................................................
............#.............................................................................................#......#................#.........
...#..........................#..........................#......................................#...........................................
............................................................................................................................................
........#.............#...................................................#.................................................................
...........................................#....................#.................#...........................#......#.........#............
............................................................................................................................................
............#....................#.............................................................#......#.....................................
.....................................................................#..................#...................................................
.....................#..............................#........#...............#........................................................#.....
....................................#...................................................................................#...................
..................................................................................................................#.........................
.....#.......#...............#..................................................................#..............................#............
.............................................#.........#....................................................................................
..................................................................#.......#................................#................................
.........................#.................................................................#.......#.................#......................
#...............................................#.........................................................................#.......#.........
...........................................#.................#................#...........................................................#.
......................#...............#............................................#........................................................
...............#..............#....................#....................................#.........................#.........................
..#..........................................................................................................#..............................
..........#...................................................................................#........#....................................
...........................#.......#.........#.........#..................#.................................................................
................................................................#......................................................#....................
............................................................................................................................................
...............................................................................................................................#............
........#...............................#............#...................................................#........#....................#....
....................#.......................................................................................................................
............#...................................#....................................#................................#.....#...............
.............................#....................................#...............................#.........................................
...#....................................................#..................#...........................#....................................
.......................#..............#..................................................#...............................#........#.........
..............#.................#............................................................................#..............................
........#..........................................#......................................................................................#.
..........................#............................................#.....#.......................................#......................
...................................#.....................#........#...............#.........#...............................................
...........................................................................................................................#................
.........................................#.............................................................#...........................#........
......#.........................#...........................#............#.....#............................................................
...............#.....#.................................#.......................................................................#............
..................................................................................................#..............#........................#.
...................................#.......#................................................................................................
..............................................................#......................#..................#.........................#.........
..............................#.................#.........................................#.................................................
..#.........................................................................................................................................
..................#..................................................#......#......................#........................#...............
...........#...........................................................................................................#..............#.....
.....................................#......................................................................................................
........................................................#.........................................................#.........................
..........................#....................................#............................................................................
............................................................................................#...............#............................#..
#..............................................#...................................#..................#.....................................
.........#.............#..................#.....................................................................#...........................
.............................................................................................................................#..............
.....................................#...........................#............#..................#.....................................#....
.................#..........#............................#..............................................................#........#..........
.........................................................................#...................#..............................................
.................................#...........................................................................#.....#........................
........................................#..........................#........................................................................
...#.....#.................................................#......................................#......#..........................#.....#.
....................................#.............................................#.........................................................
....................#.......#................#..............................#...............................................................
.....................................................................#....................#....................#............................
.................................................#................................................................................#.........
...........#...........#...................................................................................................................#
................#.......................#.........................#...................................................#.....................
...#.......................#...............................#.........................................#.........................#............
....................................................................................#.......................................................
.............................................................................................#...........................................#..
..............#...............................#................................................................#..........#.................
.......................................................#.............#.....#................................................................
............................#...................................................................#...........................................
.....#..............................#...........................................................................................#..........#
..................................................#...............#................#........................................................
..........#..........#.......................................................................................#.........#.............#......
........................................................#....................................................................#..............
.............................#...................................................................................#.......................#..
.#.........................................#...................#...........#..........................#.....................................
....................................................................#......................#................................................
...........#......................................................................#.................................#.......................
.....#.................................................................................#.......................................#............
...............................#.....#..................................................................#...................................
....................#.........................#......................................................................................#......
..................................................................................................#...........#........#....................
...............#.........................................#............#.....................................................................
..................................#......#....................................#.............................................................
...........................#........................#.....................................#..............#...............................#..
....#..............#..............................................................................................#.........................
.............#...................................................................................#..........................................
...................................................................................#..................#..................#............#.....

10
11/input-ex Normal file
View File

@@ -0,0 +1,10 @@
...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#.....