Prime Factors Golf

Smylers Belfast-PM at stripey.com
Thu Mar 28 14:57:59 CST 2002


Liyang Hu wrote:

> On Wed, Mar 27, 2002 at 09:07:17PM +0000, Smylers wrote:
>
> > $%=pop;$/=2;$%%$/&&$/++or$%/=$/,push@%,$/while$%>1;@%or@%=$%;$,=' x ';print@%
>                                                      ^^^^^^^^^^
> Why do you need that bit? I wouldn't bother, at least not by my
> definition of `factorisation', or what a factor is.

I think it was part of the spec that it should cope with any integer
from 0 or above, with 0 and 1 just emitting themselves respectively.

> Also, if you're willing to dispense with the spaces between the
> factors,

Yeah, I wasn't sure about those.  Unfortunately I've lost the spec, but
I think there were spaces in the sample output.

> you can shave off a further, not 2, but 4 strokes: (Thanks to Tony for
> that one.)

Cunning.

> > $%=pop;$/=2;$%%$/&&$/++or$%/=$/,push@%,$/while$%>1;$,=x;print@%
>
> 63 strokes. ^_^

Smylers




More information about the Belfast-pm mailing list