Perl Christmas Quiz 2009

Chris Jack chris_jack at msn.com
Mon Nov 30 23:40:04 GMT 2009



Abigail abigail at abigail.be wrote
> 
> On Mon, Nov 30, 2009 at 06:24:12PM +0000, Chris Jack wrote:

> > 7) Write a one line program that takes a non-negative integer as an argument
> > and prints the square root when the answer's an integer.
> > 
> > Restrictions: the perl line should be a regular expression.
> 
> Just a regular expression? Regular expressions don't print, so that would
> be impossible.


Pedant. Perl regular expressions allow execution of arbitrary code blocks - which is why I put restrictions on which "ordinary" functions you were allowed to use. The actual square root algorithm, however, should only use the "normal" regular expression bestiary.

 

I was going to point you towards my talk on Perl one-liners - which shows the basic idea behind prime number checking and solving linear equations - but I can't find any of the talks on the London Perl Mongers website... The principal behind doing square root is similar but different.

 

As far as I'm aware, no-one has published this previously - so you can claim bragging rights if you do it before I give my solution.
 		 	   		  
_________________________________________________________________
Use Hotmail to send and receive mail from your different email accounts
http://clk.atdmt.com/UKM/go/186394592/direct/01/


More information about the london.pm mailing list