Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: (Golf) Giving Change

by iakobski (Pilgrim)
on Jun 12, 2001 at 15:14 UTC ( #87768=note: print w/replies, xml ) Need Help??


in reply to (Golf) Giving Change

Here's my entry at 67:
#2345678901234567890123456789012345678901234567890123456789012345678 sub c{($t,$p)=@_;for(reverse@$p){until($t<$_){push@r,$_;$t-=$_}}@r}
Based on tadman's original.

update

boo_radley just pointed out this is in fact 54. Where do I find the rules to this sport?

-- iakobski

Replies are listed 'Best First'.
Re: Re: (Golf) Giving Change
by MeowChow (Vicar) on Jun 12, 2001 at 20:22 UTC
    I'm not sure how boo_radley counted 54 - it's actually 60. You count only the characters inside the sub. You should also add three characters to reset @r (thereby making this sub usable more than once).

    Anyway, here's a solution at 54:

    sub c{($t,$p)=@_;map{$t-=($x=int$t/$_)*$_;($_)x$x}reverse@$p}
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://87768]
help
Chatterbox?
Corion idly wonders if there is a way to produce ordered .yml files. I want to accept YAML for a configuration file format, but I also want to generate (for debugging/start) a sample configuration file from the current configuration.
[Corion]: Ideally, that configuration file would have some order of the keys, but I'm not sure whether/how YAML supports ordered output.
[Corion]: Basically I have this metadata and generating a purposeful example is much better if the output is ordered in the same way the documentation is ordered

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-01-16 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (149 votes). Check out past polls.