Eugene van der Pijll wrote: > > En op 10 maart 2002 sprak [EMAIL PROTECTED]: > > > Rick is a brilliant golfer and I feel sure he would have found the > > same "ugly" improvement from s/$&/$&/g to split$& had he not been > > suffering from the giggles. > > That was NOT an ugly improvement, IMNSHO. When I thought up the idea of > counting the fenceposts, I had about the same reaction as Rick when he > found the s/$&/$&/ solution.
That split$& was a brilliant move, not ugly at all. I look at that one as asking the right question: "do you want to count items, or the gaps between items?" Sometimes it's not finding a good answer that's important, it's finding a good question! > > > 3) Be pragmatic. Don't get too carried away with fanciful solutions. > > > > This is a common failing among chess players; they spend an hour > > or more analysing a fanciful line, only to reject it and find > > themselves in time trouble later in the game. > > > > Perhaps, Eugene and Stephen Turner fell into this trap in the > > secret number game, where they both pursued deliciously complex > > variations involving the (${}) construct in preference to simpler > > more pragmatic solutions involving s///eg. > > Actually, I did look for other solutions; I just could not find them. > I did not try the s///eg within s///eg way, as I was sure that couldn't > work. Earlier, I had tried things like m#___(?{___/./___})___#, which > produced an error message about non-reentrant regex-routines. > > I know... I should have tried anyway. I missed moving from 47 to 46 on Base36 because I was sure I couldn't put an assignment in a "map" without braces. I was wrong... :( > > Most of the top Perl golfers have such good technique that if you > > throw them an idea, they can quickly refine it into a solution. > > But how do you find the ideas? > > Read manpages. Perlrun, perlvar, perlfunc and perlre especially. > > Turn off the computer and go do something else that does not require > much thinking. I get most ideas in the shower, in bed just before I go > to sleep, or while riding a bike to/from work. (If anyone on fwp lives > around Utrecht & drives a car: please be careful during golf games. > Thank you.) I solved wc.pl in the shower. I did most of my improvements on even.pl in bed (no, I don't have a computer in there). I found "*1.11%10" and how to eliminate the "chop" in, ahem, "another room" of the house :) Try applying the "Monty Python" rule: "And now for something completely different." If you're using a formula, try a regex. If you're using a regex, try a formula. After I found the s/$&/$&/g, I spent at least an entire day trying to find a regex for even.pl so that the entire solution would be: -p s/REGEX// but never could find a REGEX short enough. (I hope these tips don't help anyone - there are enough sharks out there :) -- Rick Klement