in reply to (Golf) Fibonacci Strings
I found all the solutions interesting (even those that let 'ab' slide through). For my own entry, I wanted to do it all in one regex and succeeded but the initial cost was nearly 90 characters. After a dinner and beer break I managed to simplify it out (I was using an extra grouping that wasn't needed), and was then able to use a bit of japhy's techniques to squeeze down to tie at 74:
sub is_fibo { pop=~/^(?{$x=$y=0})(?:(.)(??{"\Q$1"x$y})(?!\1)(?{$y=($x+=++$y)-$y})){3 +,}$/ }
Even passes 'strict' in 5.6.1, but not in 5.00503. Of course, there is the distinct possibility that my brain is mushier than I think from the beer and I'm missing some obvious failure mode with this one.
Update: Doh! And along comes japhy to casually make a putt I completely missed for a 2 stroke savings ... probably only used one hand too :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (Golf) Fibonacci Strings
by japhy (Canon) on Jul 20, 2001 at 16:07 UTC |