Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

(Golf) Giving Change

by tadman (Prior)
on Jun 12, 2001 at 03:39 UTC ( [id://87681]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        print join(',',c(22.50,[.01,.05,.1,.25,1,5,10,20,50,100]));
  2. or download this
        20,1,1,0.25,0.25
  3. or download this
        print join(',',c(22.50,[.01,.05,.1,.20,1,2,5,10,20,50,100]));
  4. or download this
        20,2,0.2,0.2,0.1
  5. or download this
    sub c{
    ($t,$p,@r)=@_;@p=map{int($_*100)}@$p;
    $t=int($t*100);while($v=pop@p and$t>0
    ){while($t>=$v){push@r,$v/100;$t-=$v;
    }}@r
    }
    
  6. or download this
         print "$t != $v\n" if ($t != $v);
  7. or download this
         0.1 != 0.1

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://87681]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found