Beispiel #1
0
        private static void InfiniteCombinationGenerator_CalcChange()
        {
            var generator=new InfiniteCombinationGenerator(1,2,5,10,20,50,100);

            generator.Generate(60,change=>
            {
                var text=string.Join(", ", change.Collapse());
                Console.WriteLine("{0} coins => {1}",change.NumberOfCoins(),text);
            });
        }
        public void ZeroPence()
        {
            var generator=new InfiniteCombinationGenerator(1, 2, 3);

            int combinations=0;

            generator.Generate(0, change=>
            {
                var text=string.Join(", ", change.Collapse());
                Console.WriteLine(text);

                combinations++;
            });

            Assert.IsTrue(combinations==0);
        }