Skip to main content

Timeline for Refactoring Pset1 Greedy Modulo

Current License: CC BY-SA 3.0

3 events
when toggle format what by license comment
Dec 14, 2017 at 10:16 vote accept ExpertShaun
Dec 13, 2017 at 23:45 comment added Cliff B While loops will work, the technique that ExpertShaun used is far more efficient. The improvement, as @curiouskiwi suggested, is to use a single var, coins, to accumulate the coins, eliminating the need for a,b,c and d. Consider this. Say that the amount is $1,000,000. A loop would have to execute 4 million times to get the answer. With ExpertShaun's technique, the program executes exactly 8 calculations, no matter what the starting amount of cash. It could be simplified to 7, but I'll leave that for anyone else to figure out for themselves. ;-) (don't post it here.)
Dec 13, 2017 at 16:29 history answered WhipStreak23 CC BY-SA 3.0