Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: [golf] Kaprekar Numbers

by Roy Johnson (Monsignor)
on Jul 05, 2005 at 19:47 UTC ( #472580=note: print w/ replies, xml ) Need Help??


in reply to [golf] Kaprekar Numbers

41:

$_=$_[0]**2;$==y///c/2;/.{$=}/;$&+$'==pop

Caution: Contents may have been coded under pressure.


Comment on Re: [golf] Kaprekar Numbers
Download Code
Re^2: [golf] Kaprekar Numbers
by truedfx (Monk) on Jul 07, 2005 at 20:36 UTC
    Based on your idea, I got it to 38:
    # 34567890123456789012345678901234567890 $_=$_[0]**2;pos=y///c/2;//g;$`+$'==pop
    (Edit: and using thospel's "@_" instead of $_[0] makes it 37. I wonder how I managed to miss that...)
      Like this it's 34:
      (pos=$_="@_"**2)/=2;//g;$`+$'==pop

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-12-29 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (183 votes), past polls