Created
October 2, 2013 04:50
-
-
Save MikeBild/6789264 to your computer and use it in GitHub Desktop.
Coin Changer with LINQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var amount = 99; | |
(from n in new[] { 1, 2, 5, 10, 20, 50, 100 } | |
orderby n descending | |
select new { Coin = n, Number = amount / n, Spare = (amount %= n) }).Dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment