PCLP#16 golf
Mtv Europe <[email protected]>
| Newsgroups | gmane.comp.lang.perl.golf |
|---|---|
| Message-ID | <[email protected]> |
Hello All!
Today PCLP#16 finished - a perlgolf run by Polish perl people:
http://kernelpanic.pl/perlgolf-list.mx
This was a very interesting golf in itself and especially the solutions
for this golf were interesting. It really deserves mention here, so I
took the liberty to do just that.
The task was to decompress a binary image of 8 x 8 pixels, each pixel
could be in two states, either 0 or 1, and the compression algorithm
is as follows:
- if a box (you'll see what a box is later) of pixels consists of only one
value, write this value;
- otherwise, divide this box on four equal parts, write the letter "D", and
then recursively repeat this algorithm for each piece in this order:
upper left, upper right, lower left, lower right.
So consider for example this image:
0 0 0 0 1 1 1 1
0 0 0 0 1 1 1 1
0 0 0 0 1 1 1 1
0 0 0 0 1 1 1 1
1 1 1 1 0 0 0 0
1 1 1 1 0 0 0 0
1 1 1 1 0 0 1 0
1 1 1 1 0 0 0 0
Recursively divides on this parts:
0 0 0 0|1 1 1 1
|
0 0 0 0|1 1 1 1
|
0 0 0 0|1 1 1 1
|
0 0 0 0|1 1 1 1
-------+-------
1 1 1 1|0 0|0 0
| |
1 1 1 1|0 0|0 0
|---+---
1 1 1 1|0 0|1|0
| |-+-
1 1 1 1|0 0|0|0
Writing it all out, the compressed string will be D011D000D1000.
The task now is to decompress such a string. The string terminated with
newline comes from STDIN, the rest is as usual.
You can find a test script at:
http://kernelpanic.pl/perlgolf-download-test.mx?id=18
To avoid spoiling, this letter has no solutions, but you can find them on
the web site. The winning solution by Piotr "0xF" Fusik was an absolutely
dazzling 80 that every golfer should see.
--
Mtv Europe, with edition and signature dash by Ton Hospel