Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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.
                   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?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-09-21 14:17 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (172 votes), past polls