And here's my simple logical non-mathematician version! function coinChange pChange repeat for each item x in "50, 20, 10, 5, 2, 1" repeat while pChange >= x subtract x from pChange add 1 to y end repeat if y > 0 then put y && "x" & x & "c" & cr after tResult put 0 into y end repeat return tResult end coinChange
Paul On 2013-01-30, at 7:16 PM, Mark Wieder wrote: > Today's algorithm challenge: > > Determine the minimum number of coins for change. > > Given any number between 1 and 99, determine how to give change with > the minimum number of coins. You can assume that the coins are 1c, 2c, > 5c, 10c, 20c and 50c. > > Various solutions here in Scala, java, C#, Groovy... > http://java.dzone.com/articles/thursday-code-puzzler-change > > ...and the xtalk implementation would be... > > -- > -Mark Wieder > mwie...@ahsoftware.net > > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode