day 12, draw montain

This commit is contained in:
setop 2022-12-14 01:18:14 +01:00
parent e62a2c70b7
commit f3177e66a3
3 changed files with 30 additions and 0 deletions

View File

@ -1 +1,6 @@
pandoc -o fail.pdf -t pdf fail.md pandoc -o fail.pdf -t pdf fail.md
awk -f draw.awk < input >| input.pgm
convert input.pgm -scale 1600% input.png
base64 input.png | tr -d '\n'

20
d12/draw.awk Normal file
View File

@ -0,0 +1,20 @@
BEGIN { print "P2"
print "81 41"
print "25"
}
{
split($0,arr,"")
r = ""
#for (a in arr) {
# print a, arr[a]
#}
#nextfile
for (i=1;i<=81;i++) {
c = arr[i]
if (c == "S") { v = 0 }
else if (c == "E") { v = 25 }
else { v = index("abcdefghijklmnopqrstuvwxyz", c)-1 }
r = r " " v
}
print r
}

5
d12/viewpng.html Normal file
View File

@ -0,0 +1,5 @@
<img>
<script>
let img = document.querySelector('img');
img.src = "data:image/png;base64,"+ window.location.hash.substring(1);
</script>