Skip to content

Instantly share code, notes, and snippets.

@MikeBild
Created October 2, 2013 04:50
Show Gist options
  • Save MikeBild/6789264 to your computer and use it in GitHub Desktop.
Save MikeBild/6789264 to your computer and use it in GitHub Desktop.
Coin Changer with LINQ
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