From f3177e66a3659fe111ca60dbaa30e86a780d0477 Mon Sep 17 00:00:00 2001 From: setop Date: Wed, 14 Dec 2022 01:18:14 +0100 Subject: [PATCH] day 12, draw montain --- d12/cmd.txt | 5 +++++ d12/draw.awk | 20 ++++++++++++++++++++ d12/viewpng.html | 5 +++++ 3 files changed, 30 insertions(+) create mode 100644 d12/draw.awk create mode 100644 d12/viewpng.html diff --git a/d12/cmd.txt b/d12/cmd.txt index 6545496..18212c6 100644 --- a/d12/cmd.txt +++ b/d12/cmd.txt @@ -1 +1,6 @@ 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' diff --git a/d12/draw.awk b/d12/draw.awk new file mode 100644 index 0000000..6d56a00 --- /dev/null +++ b/d12/draw.awk @@ -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 +} diff --git a/d12/viewpng.html b/d12/viewpng.html new file mode 100644 index 0000000..b2fb999 --- /dev/null +++ b/d12/viewpng.html @@ -0,0 +1,5 @@ + + \ No newline at end of file