Bool array for pixels

This commit is contained in:
2022-12-10 09:22:10 +02:00
parent 5849a1bab2
commit 81cd38b592
2 changed files with 9 additions and 373 deletions

21
10/j.py
View File

@@ -1,4 +1,5 @@
import os
import sys
input = open(os.path.dirname(__file__) +
"/input.txt", "r").readlines()
@@ -11,12 +12,7 @@ cost = {
H = 6
W = 40
screen = []
for y in range(H):
tmp = ''
for x in range(W):
tmp += '.'
screen.append(tmp)
screen = [[False for i in range(W)] for j in range(H)]
cycle = 1
X = 1
@@ -38,9 +34,7 @@ for l in input:
line += 1
if (pos == X-1 or pos == X or pos == X+1):
cur = screen[line-1]
screen[line-1] = cur[:pos] + "#" + cur[pos+1:]
screen[line-1][pos] = True
cycle += 1
@@ -52,7 +46,10 @@ print(sum(strs))
# p2
for y in range(H):
tmp = ''
for x in range(W):
tmp += screen[y][x]
print(tmp)
if (screen[y][x]):
print("#", end="")
else:
print(".", end="")
print()