Filtration Residue
Posted: Thu Jul 22, 2010 6:04 pm
I loved this challenge. I learnt so much more about the PNG format and I thought that the idea was brilliant. Kudos to teebee - it must have taken ages to create.
Code: Select all
pngcheck -vv residue.png | perl -ne 'if ($a) { $a = 0; push @a, map { $_ + 0 } split /\s+/, $1 if /^\s+((\d\s)*\d)/ } else { $a = 1 if /row filter/ } END { print"@a" }' | perl -lne 'BEGIN { %a = (0, "11", 1, "010", 2, "011", 3, "10", 4, "00") } $a .= join "", map { $a{$_+0} } split /\s+/; END { print map {chr} map { eval '"'"'$_ = 0b'"'"'.$_ } $a =~ /.{8}/g }'
teebee wrote:Thanks, I am pleased that you enjoyed the challenge. To create the image I patched `pngtest.c' and `pngwutil.c' of the libpng library (http://www.libpng.org/pub/png/) which wasn't such difficult.
Using `pngcheck' and `perl' the challenge can be solved in one line as follows:Code: Select all
pngcheck -vv residue.png | perl -ne 'if ($a) { $a = 0; push @a, map { $_ + 0 } split /\s+/, $1 if /^\s+((\d\s)*\d)/ } else { $a = 1 if /row filter/ } END { print"@a" }' | perl -lne 'BEGIN { %a = (0, "11", 1, "010", 2, "011", 3, "10", 4, "00") } $a .= join "", map { $a{$_+0} } split /\s+/; END { print map {chr} map { eval '"'"'$_ = 0b'"'"'.$_ } $a =~ /.{8}/g }'
Yep, definitely. This one was teaching.helly0d wrote:Nice challenge. Nice one teebee.