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

Re: Re: (Golf) Kaprekar's Process

by srawls (Friar)
on Jun 16, 2001 at 23:07 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://89082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-16 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found