I've got Pset 1, 'Greedy' working, I just think I can refactor it better. How can I get rid of ints a, b, c and d?
a = amount /25; amount = amount % 25;
b = amount /10; amount = amount % 10;
c = amount /5; amount = amount % 5;
d = amount /1; amount = amount & 1;
coins = (a+b+c+d);
where amount is the rounded amount inputted.
Thanks
amount = amount & 1;
at the end? The&
operator is a bit shift operator. I can't figure out what you were doing here, or is it a typo? Fortunately, it has no effect on the program since amount isn't used after this. Second, what happens when you divide any number by 1? ;-)