[cam.pm] Christmas Perl Programming

Matthew Byng-Maddick cam-pm@lists.colondot.net
Sat, 7 Dec 2002 02:40:09 +0000


So, in the summer, I suggested in
  http://www.cam.pm.org/archive/2002-May/000761.html
that we should have a small programming contest. I learnt a number of things
from this, such as appropriate amounts of time, etc. I've also been known
to do little fun programs at christmas time, with an approximately
christmassy theme - eg:
  http://www.cam.pm.org/archive/2001-December/000489.html

So, it seemed pretty obvious that I could combine the two. The rules on the
entries will be stricter, and the prize will be more tangible.

The rules are very simple:
* a valid programme entry (such as the example below) can be overlaid by
  the template below in such a way that the characters in the entry are
  non-whitespace if the corresponding character in the template is a "#"
  and that they are whitespace if the corresponding character is a " ".
  Trailing space will be ignored.
  (Tabs will be rendered as " " to the nearest tabstop, and tabstops
  occur every 8 characters). Entries not conforming will be rejected as
  part of the competition, but may well end up in the final summary.

* Entries must be submitted to christmas-perl@cam.pm.org by
  2003-01-01 00:00:01

* Multiple entries are allowed per person

* Entries should be submitted with any environment variables, such as
  LINES or COLUMNS, that might need setting. No non-standard environment
  variables will be allowed from the command line. Setting the tty modes
  using stty(1) shall also be allowed, and other such I/O settings. Forms
  of any required arguments would also be good, or files that need to be
  opened.

* Entries are considered secret by the judges until the announcement of
  the winner and the publication of the summaries (this publication will
  be announced on the cam.pm list). Copyright of the entry remains with
  the original author, but the competition judges, and cam.pm are granted
  a non-exclusive licence to be able to publish such code, and include it
  on the cam.pm website.

* Pick one or more of perl 5.005_03 / 5.6.1 / 5.8.0

* The prize will be a bottle of wine, to be presented at the next available
  opportunity after the announcement of the winner.

* Open to anyone who would like to submit (except for organisers of the
  competition, obviously)

* The winner will be the most interesting programme to decipher and
  understand. Extra credit will be given for algorithmic obfuscation,
  interesting techniques of using the space allowed, and pretty results.
  The judges' decision shall be final.

-----BEGIN TEMPLATE-----
            ###                          ###
          #######                      #######
         ###   ####  ##############  ####   ###
          ############    ####    ############
          ############    ####    ############
         ##  ####   ###    ##    ###   ####  ##
        ###    ###   ####  ##  ####   ###    ###
       ######   ########## ## ##########   ######
      ##     ##############################     ##
  ####################################################
 ####  #########  ########    ########  #########  ####
 ###    #######    ######      ######    #######    ###
 ####  #########  ########    ########  #########  ####
  ####################################################
      ##     ##############################     ##
       ######   ########## ## ##########   ######
        ###    ###   ####  ##  ####   ###    ###
         ##  ####   ###    ##    ###   ####  ##
          ############    ####    ############
          ############    ####    ############
         ###   ####  ##############  ####   ###
          #######                      #######
            ###                          ###
-----END TEMPLATE-----

In order to get people to participate in this, I've done a non-entry which
conforms to all but the rule about competition organisers.

-----BEGIN MBM ENTRY-----
            sub                          l{$
          r[-1]=~                      s/./-/g
         ;a(   2,$d  );a(4,"/$e\\")  ;a(3   ,$f
          );a(5,$u.$e.    "".$    u."",1);for(
          @t){$p="(.{"    .$_.    "}";$r[-5]=~
         s,  $p.)   .,$    1.    "."   ,ex;  $r
        [0-    $_]   =~s;  $p  )...   ;$1    .""
       ."/$u"   .qq/\\/;xe ,1 for(2..4)}   $_=$z.
      ""     .join"\n",@r;print;sleep$|}sub     r{
  int(rand$_[0])}$|=1;$u=$";$e="_"x5;$a=$u."o";$b="o";
 ;sub  a{;substr  $r[-$_[0    ]],$h,7,  $_[1]}sub  t{t(
 01)    if!@_;$    k=$a;$      a=$b;$    b=$k;$r    [$_
 -01]  =~s/$a/r(  012)?$a:    $b.""/eg  for(1..$r  )}$b
  .=$u;$z="\e[H\e[J";($r,$c)=split/\s/,`stty${u}size`;
      $v     =$"x$c;$h=r($c-7);@t=map{r($c-     3)
       }(0..r   (9));$k=$b ;$ k=~s/\s//;   for(01
        ..$    r){   ($r[  $_  -1]=   $v)    =~#
         s,  \s,r   (30    )?    $":   $k#"  o"
          ,xeg}($f=$d=    "|".    "$u#$u+$u|")
          =~y/#/+/;for    (0..    $r){l;t;@r=(
         $v,   @r);  pop@r}$r[-6]="  Let"   .$"
          ."it$u"                      ."snow"
            ;l;                          $p;
-----END MBM ENTRY-----

So, while you're sitting there trying to deal with the amount of turkey
you've eaten, then see if you can come up with a programme to fit in the
snowflake, and get it in before the New Year. There are quite a few
characters to play with, and it should be possible to do something
interesting.

Happy Hacking, and good luck.

MBM

-- 
Matthew Byng-Maddick         <mbm@colondot.net>           http://colondot.net/