[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Golf (7 strokes is par!)




On 1 May 2000, Ariel Scolnicov wrote:
> Jeff Pinyan <jeffp@crusoe.net> writes:
> > Challenge: determine if $_ is an integral power of 2 (1,2,4,8,16,...)
> > I have it down to 7 characters.  Can anyone beat that?
> 
> print"$_ is a power of 2"unless$_&$_-1;

Another answer with 7 strokes: $_&~-$_

Six strokes seems impossible to me - I'll get back as soon as my
exhaustive search finishes..

-- 
Ilmari Karonen
http://www.sci.fi/~iltzu/





==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe