day 10, prettier and a awk solution for part 2
This commit is contained in:
parent
38a377ac84
commit
c8b2258994
|
@ -0,0 +1,20 @@
|
|||
BEGIN { x=1 }
|
||||
function inc() {
|
||||
i = (c%40)
|
||||
A[c+1] = (i==x-1||i==x||i==x+1) ? "█" : "░"
|
||||
c+=1
|
||||
}
|
||||
{ inc() }
|
||||
$1 == "addx" {
|
||||
inc()
|
||||
x+=$2
|
||||
}
|
||||
END {
|
||||
for (i=0;i<=5;i++) {
|
||||
r = ""
|
||||
for (j=1;j<=40;j++) {
|
||||
r = r A[i*40+j]
|
||||
}
|
||||
print r
|
||||
}
|
||||
}
|
|
@ -2,14 +2,14 @@ import sys
|
|||
|
||||
X = 1
|
||||
C = 0
|
||||
LCD = [["."]*40 for _ in range(6)]
|
||||
LCD = [["░"]*40 for _ in range(6)]
|
||||
|
||||
def inc():
|
||||
global C
|
||||
(r,c) = divmod(C, 40)
|
||||
C+=1
|
||||
if c in [X, X-1, X+1]:
|
||||
LCD[r][c]="#"
|
||||
LCD[r][c]="█"
|
||||
|
||||
for l in sys.stdin.read().splitlines():
|
||||
m, q = (l+" _").split(" ")[:2]
|
||||
|
|
Loading…
Reference in New Issue