From:

Date:

May 8, 2002 18:31Subject:

RE: can someone please explain..Message ID:

Pine.SOL.3.95.1020509025737.7763U-100000@ultra14.almamedia.fi-----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 golfable. 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 too.. yes!" 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): #!perl push@$,($")x$#$,@$?@$:'-'for$!..pop;print"@$ " (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! -Bass - -- 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----- Version: 2.6.3i Charset: noconv iQB1AwUBPNnRZfbPZUB64qcJAQG8cAMApLYxQgkHFM2B0swDhSs6yRJU1of9n2QF RORTr89fzeRwMYKoUVYhibNBZIZ4ocKcFeA4yJkhkMAZXvSeB52LblcfwPVljfOV n85nRxwHlf2PTaIS9qVDFhAJKtFDJmlS =0zuK -----END PGP SIGNATURE-----Thread Previous | Thread Next

- can someone please explain.. by Jasper McCrea
- RE: can someone please explain.. by Mark Schoonover
**RE: can someone please explain..**by Tuomo Salo- Re: can someone please explain.. by perl-golf
- Re: can someone please explain.. by Mtv Europe
- Re: can someone please explain.. by Jay Tilton
- Re: can someone please explain.. by Mtv Europe
- Re: can someone please explain.. by Marcelo E. Magallon
- Re: TPR(0,3) in review by Marko P. O. Nippula
- Re: TPR(0,3) in review by Peter Makholm
- Re: can someone please explain.. by perl-golf
- Re: can someone please explain.. by Peter Makholm
- Re: can someone please explain.. by Yanick

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About