in reply to Canadian Cryptography Contest

Apparently. :-)

Golf: (just the most obvious things)

perl -pe's!(\d)(\d)(\d)/!chr(64+$1*16+$2*4+$3)!ge' codedata

Know thine commandline switches.

Update: Doh, tilly was a few minutes faster.

Update 2: Slightly longer but I like this better:

perl -pe's!(\d..)/!$x=1;($x*=4)+=$_ for split//,$1;chr$x!ge' codedata

Update 3: Thanks to tadman:

perl -pe's!(\d..)/!$x=1;($x*=4)+=$_ for$1=~/./g;chr$x!ge' codedata

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: Canadian Cryptography Contest
by tadman (Prior) on Jan 22, 2002 at 20:20 UTC
    Then, of course, you would do the following:
    for(1..1e6){$s+=$_ for/./g};print$s
    Unfortunately, map seems to choke on 1e6 entries.
      perl -e'map$\+=$_,/./g for 1..1e6;print'
      also works. OTOH before this is done running you should be able to reason out why the answer is 27,000,001. (Big hint. The 1 is the contribution from the 7'th digit.) As for map chocking, if you are on any Perl before 5.6.1, the many for one map shows quadratic performance, so it will indeed choke and remain choked for a good while on a million entries.
        map choked completely, by using massive amounts of memory.
        This is perl, v5.6.1 built for i686-linux
        Must be one of those things.
      Ok, explain. Try as I might I can't figure out what you're trying to get at.

      Makeshifts last the longest.