Re: Hamming minigolf post mortem

Mtv Europe <[email protected]>
Newsgroups gmane.comp.lang.perl.golf
Message-ID <[email protected]>
Hello Peter!

[email protected] wrote:
> Can anyone explain what is going on in mtve's solution?

Hmm, let me take a try.

First, it uses $^C variable that happens to be 8 bit in perl, so
it wraps at 128 (-127) - cheap counter.     $^C % 6 becomes
integer in range 0..5 - multiplicator for creation of new numbers.

Second, it uses "furl" of hamming numbers to more compact space:
   $constant * log ($number)
so it becomes possible to keep them in perl array under generic rules,
array name ':' is highly convenient here because it's the only
non-letter char that allows '$#:' construct.

Third, on each iteration of loop, array size is truncated to exactly
4096 numbers in return.    This limit happened to be 77777 which
was golfed to 7x5.

Fourth, last iteration of loop doesn't modify an array since in this
time $^C == 1 and thus it multiplies numbers by 1 (does nothing),
so it's possible to put array truncation before map.   That's why
i use --$^C not usual ++$^C.

Fifth, i didn't need zero, because logarithm of zero is an exception,
so i needed ($multiplicator * $number or 1) where 'or' is '||' operator.
But at that moment perl decided to crash my solution, and to recover
situation i've applied my own rule about necessity of regexes -
i've replaced 1 with // and, duh, it helps.

That's all.

P.S. After this lecture you should be able to describe why there are
floating numbers in the output of following code:

map{$_<1|$_>10 or $a[800*log]=$_.$/ for $_*$' } @a,//for 1..5;print@a

---
Mtv Europe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.