Bool array for pixels
This commit is contained in:
21
10/j.py
21
10/j.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user