Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 wandering the Monastery: (19)
As of 2015-08-28 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (336 votes), past polls