Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: (Golf) Kaprekar's Process

by srawls (Friar)
on Jun 16, 2001 at 23:07 UTC ( #89082=note: print w/ replies, xml ) Need Help??


in reply to Re: (Golf) Kaprekar's Process
in thread (Golf) Kaprekar's Process

Humm, I just counted manually and you're right, it is 79. I wonder why this prints 60:

print length("return$i if$_[0]==495;$a=join'',sort{$a<=>$b}" ."split//,pop;$i++;a((reverse$a)-$a)");
Anyway, nice improvements, I should've caught that sort one : )

Update:Ooops, thanks MeowChow.

The 15 year old, freshman programmer,
Stephen Rawls


Comment on Re: Re: (Golf) Kaprekar's Process
Download Code
Re: Re: Re: (Golf) Kaprekar's Process
by MeowChow (Vicar) on Jun 16, 2001 at 23:18 UTC
    You're double-quoting the code, which means that the variables are getting interpolated into undef 0-length strings.
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
Re: Re: Re: (Golf) Kaprekar's Process
by mr.nick (Chaplain) on Jun 17, 2001 at 03:35 UTC
    And I can take it down a litter further massaging your code into this:
    sub g{ # 1 2 3 4 5 6 + 7 # 12345678901234567890123456789012345678901234567890123456789012345678 +9012 return$,if($_=pop)==495;$_=join'',sort split//,$_;$,++;g((reverse)-$ +_) }
    But I can't do one on my own... my own solution came in at 83 :(

    mr.nick ...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (18)
As of 2015-07-06 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls