Last active
August 29, 2015 13:56
Revisions
-
adamwitko revised this gist
Feb 7, 2014 . 1 changed file with 19 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,24 @@ internal class Program { private static readonly int[] _denominations = {1, 2, 5}; private static void Main(string[] args) { const int total = 6; var result = GetCount(amount, 0); Console.WriteLine(result); Console.ReadLine(); } public static int GetCount(int amount, int index) { if (amount == 0) return 1; if (amount < 0 || _denominations.Length == index) return 0; return GetCount(amount - _denominations[index], index) + GetCount(amount, index + 1); } } -
adamwitko renamed this gist
Feb 7, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
adamwitko revised this gist
Feb 7, 2014 . 1 changed file with 3 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,24 +6,19 @@ { const int total = 6; var result = GetCount(amount, 0); Console.WriteLine(result); Console.ReadLine(); } public static int GetCount(int amount, int index) { if (amount == 0) return 1; if (amount < 0 || _denominations.Length == index) return 0; return GetCount(amount - _denominations[index], index) + GetCount(amount, index + 1); } } -
adamwitko revised this gist
Feb 7, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,13 +17,13 @@ return Recurse(amount, 0); } public static int Recurse(int amount, int index) { if (amount == 0) return 1; if (amount < 0 || _denominations.Length == index) return 0; return Recurse(amount - _denominations[index], index) + Recurse(amount, index + 1); } } -
adamwitko created this gist
Feb 6, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ internal class Program { private static readonly int[] _denominations = {1, 2, 5}; private static void Main(string[] args) { const int total = 6; var result = GetCount(total); Console.WriteLine(result); Console.ReadLine(); } public static int GetCount(int amount) { return Recurse(amount, 0); } public static int Recurse(int amount, int checkFromIndex) { if (amount == 0) return 1; if (amount < 0 || _denominations.Length == checkFromIndex) return 0; return Recurse(amount - _denominations[checkFromIndex], checkFromIndex) + Recurse(amount, checkFromIndex + 1); } }