Front page | perl.golf |
Postings from May 2002
RE: can someone please explain..
From: Tuomo Salo
May 8, 2002 18:31
RE: can someone please explain..
Message ID: Pine.SOL.3.95.1020509025737.7763Ufirstname.lastname@example.org
-----BEGIN PGP SIGNED MESSAGE-----
On Wed, 8 May 2002, Mark Schoonover wrote:
> Now, here's what I've
> noticed about the various tourneys - at what percent of the solution is
> coming up with a good algorithm??
Coming up with as many as possible algorithms is IMHO the most impotant
thing in golfing, you never know which one of them turns out to be the most
The worst thing that can happen is that you have thought of the _second_
most golfable algorithm, and your mind gets stuck with it. Then you just try
to shorten it any way you can, and the best algorithm will not occur to you.
happened last month.. ("Alma Media Golf Team" then, in case you wonder)
This month I got myself stuck for quite a long time at both of the holes,
but there is a story to my finding the "correct" algorithm for cantor, which I
think warrants for being told here..
After golfing for a couple of days, I showed an implementation of a
(obviously suboptimal) cantor algorithm to a friend of mine, and promised to
pay him a boozing night if he could remember it after the coffee break was
over. It overused punctuation and the algorithm was _weird_, so I felt quite
safe.. But of course he remembered. So that night, after some heavy
drinking as we were out having a smoke, it somehow crept into my mind..
"what if I replaced the hyphen with a '- -'.. no but it won't work because
there will not be enough spaces.. maybe replace the spaces with three spaces
so, it seems, the best ideas come when you least expect it.
interestingly, the code which cost me quite a lot of beer implemented an
algorithm that no-one seems to have used (maybe everyone thought of a better
one :-), so here it is, for a score of (46.12):
(You must already have decoded more cryptic code than is healthy,
so here's a brief explanation to go:
essentially, every second letter of the cantor set os generated, and
perl then adds the missing spaces between the array elements -> voilà.
sorry about using @$ for the array (although I find the "$#$" construct
somehow pleasing.. time for immediate medical care?) and using "$!"
instead of " 0", all this only to improve the tiebreaker.. shame about
the x operator being a word character :-)
> The Perl itself is tough enough, but from
> what I've been able to ascertain from all the tourneys so far is that all
> the entries have really cool (tm) algorithms! Where does one pick up those
> skills?? Basic questions I know, but this is a major stumbling block for
> some, including myself!
I got the idea for "base-3 (or ternary) numbers" algorithm by making a
search with google, and this "skip every second letter" idea came from
studying the pattern that was to be generated. google also helped me
getting started with kolakoski. the other algorithms (some trivial and
some nontrivial) "just came from somewhere" :-)
> Great job to all those that referred and submitted soln!
yes, thank you all and cu next month!
This is my personal opinion and it does not reflect the views or opinions of
my employer in any way or anything and so on and so forth.
PGP public key at http://almamedia.fi/~tasalo/tasalo.asc
-----BEGIN PGP SIGNATURE-----
-----END PGP SIGNATURE-----