Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

(Golf) Giving Change

by tadman (Prior)
on Jun 12, 2001 at 03:39 UTC ( #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
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? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-05 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls