Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: computing square root by hand -- no sqrt (golf, beginner)

by jynx (Priest)
on May 09, 2002 at 20:03 UTC ( #165486=note: print w/ replies, xml ) Need Help??


in reply to Re: computing square root by hand -- no sqrt (golf, beginner)
in thread computing square root by hand -- no sqrt (golf, beginner)


a reinterpretation of japhy's solution gives 54:

$_=pop;$l^$_?$l=$_:die"$_\n"while$_=($_+$ARGV[0]/$_)/2
jynx

update: this works at 53:

$_=pop;$l^$_?$l=$_:die"$_\n"while($_+=$ARGV[0]/$_)/=2
update2: using the comma instead of quotes for die it's 52:
$_=pop;$l^$_?$l=$_:die$_,$/while($_+=$ARGV[0]/$_)/=2


Comment on Re: Re: computing square root by hand -- no sqrt (golf, beginner)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://165486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-12-27 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls