develooper Front page | perl.golf | Postings from August 2004

Triangles and More

Thread Next
From:
Riley
Date:
August 2, 2004 15:50
Subject:
Triangles and More
Message ID:
20040802152446.89345.qmail@onion.perl.org
Hello, All!

Mtve, I thought the following short (and quite obfuscated) entry was
particularly brilliant. I wanted it to be shorter so it could be the winning
entry...

-lp $_=s/./$z|=11x$&;1x$&/eg&/$z/

It reminds me of someone's clever way of determining if a number is prime,
which (at least in my version) turns out to be of similar length:

-l print 0|(1x pop)!~/^(11+)\1+$/

I'm writing the above from memory, so I'm not sure if it's exact. Does
anyone know the origin of this algorithm? Was it the result of some ancient
golf?

Many thanks,
Riley
(o0lit3)

P.S.
For those inconvenienced, sorry for all the bugs in the testsuite of
Mastermind



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About