aoc2022/d22/draw.awk

37 lines
518 B
Awk
Raw Permalink Normal View History

2022-12-22 22:54:52 +00:00
BEGIN {
print "P2"
#print "150 200"
print "604 805"
print "2" # max
C = ""
for (i=1;i<=150;i++) { C = C " " }
}
function sep() {
r = ""
for (i=1;i<=604;i++) {
r = r "1 "
}
print r
}
NR == 1 { sep() }
{
split($0 C,A,"")
r = "1 "
for (i=1;i<=150;i++) {
c = A[i]
if (c==" ") p="2"; #"1";
if (c==".") p="2";
if (c=="#") p="0";
r = r p " " p " " p " " p " "
if (i%50 == 0) {
r = r "1 "
}
}
print r
print r
print r
print r
}
NR % 50 == 0 { sep() }