develooper Front page | perl.golf | Postings from May 2002

Re: TPR(0,3) in review

Thread Previous | Thread Next
From:
Marko P. O. Nippula
Date:
May 10, 2002 03:46
Subject:
Re: TPR(0,3) in review
Message ID:
Pine.OSF.4.10.10205101256260.18090-100000@alpha.hut.fi
On Wed, Wed, 8 May 2002  Eugene van der Pijll wrote:
> Among the entries, there were some that had something extra. They used a
> new, unique or surprising technique, used an unusual method, or were
> just ununderstandable. Some of these are:

> Kolakoski:  Rick Klement (54.25)
>             Mtv Europe (56.18)
>             Rick Klement (57.20)
>             Marko Nippula (69.23)

Sorry for delay, I've been busy for a while.

The 69.23 entry is:
-l @_=(map{(@ARGV[$.++&1])x$_}@_,$.=2)[0..$ARGV[2]-1]for%{::};print@_
I assume surprising part is                          ^^^^^^^^.

First uninteresting parts:

map{(@ARGV[$.++&1])x$_}@_ is extender for Kolakoski seq. Given valid
Kolakoski seq it will build a longer one assuming @ARGV is set correctly
and $. is even at the beginning of each round. In order to get $. to
even value and to get some initial sequence for extender ,$.=2 was added.
"2" is actually usually not a valid sequence but for that extender it
works as valid seed and starts producing valid seq. (For better
explanations look eg. Rick's explanation for his entry: 
http://archive.develooper.com/golf@perl.org/msg00594.html - although he
worked with strings the idea is the same.)

[0..$ARGV[2]-1] was to choose only required number of stuff from the
beginning of the array so that at the end only required number of digits
is returned and so that the whole memory space doesn't fill up (this
would happen with big digits like 9 8).

To generate long enough sequence (500 or more digits) looping of 13 or
more times was required. I first tried entries like

-l @_=(map{(@ARGV[$.++&1])x$_}@_,$.=2)[0..$ARGV[2]-1]for 0..12;print@_
-l @_=(map{(@ARGV[$.++&1])x$_}@_,$.=2)[0..$ARGV[2]-1]for$^F..$^H;print@_

but then I though the for sure the symbol table has to have enough junk
and I tried %{::} as in this version contents of $_ didn't matter and it
saved one whole character ;). %{::} typically contains around 30 keys so
it was more than enough to satisfy 13 loops.

Although I had already submitted 69 and something before this entry I
decided to submit this anyway as I've not seen %{::} used in golf.

For me the greatest meaning of this entry was that it compiled pretty
well into string handling code instead of array handling code and I
started getting soon some chars off. However, when looking at the final
results it looks like it would have been more beneficial to stick with
array handling and just invent bag of new tricks.

-- Marko P. Nippula <Marko.Nippula@hut.fi>, WWW: http://www.hut.fi/~mnippula/


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About