Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: Re: Re: (Golf) Kaprekar's Process

by MeowChow (Vicar)
on Jun 17, 2001 at 00:11 UTC ( #89097=note: print w/replies, xml ) Need Help??

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

That's what the sprintf is there for. It formats a two-digit result into a three-digit string, eg. 099. After sorting and reversal, you get 990 - 099.
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: (Golf) Kaprekar's Process
by srawls (Friar) on Jun 17, 2001 at 00:57 UTC
    Ok, I get it. I can modify yours than, and improve it by two chars:
    sub a { $_=pop;s/^..$/0$&/;/495/?0:1+a(-($_=join'',sort/./g)+reverse) }

    The 15 year old, freshman programmer,
    Stephen Rawls

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2016-10-23 22:14 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (302 votes). Check out past polls.