public void CalculateCyclesLengthTest()
        {
            long input = 22;
            long output = 16;
            IChallengeCalculator myComp = new Computer();
            long actual = myComp.ComputeCycleLength(input);
            Assert.AreEqual(output, actual);

            input = 19;
            output = 21;
            actual = myComp.ComputeCycleLength(input);
            Assert.AreEqual(output, actual);

            input = 22;
            output = 16;
            actual = myComp.ComputeCycleLength(input);
            Assert.AreEqual(output, actual);

            input = 38;
            output = 22;
            actual = myComp.ComputeCycleLength(input);
            Assert.AreEqual(output, actual);

            input = 44;
            output = 17;
            actual = myComp.ComputeCycleLength(input);
            Assert.AreEqual(output, actual);

        }
Exemplo n.º 2
0
       // static Dictionary<int, int> _CollatzLookup;

        static void Main(string[] args)
        {
            Console.WriteLine("Starting");
            IUserInputOutput userInputOutput = new FileUserInputOutput(_fileOutLocation);
            IChallengeCalculator challengeCalculator = new Computer();
            var inputs = userInputOutput.ReadInput();
            var outputs = new HashSet<Output>();

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            foreach (var input in inputs)
            {
                var maxCycle = challengeCalculator.CalculateMaxCycles(input);
                outputs.Add(new Output
                {
                    Input = input,
                    MaxCycle = maxCycle
                });
            }
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
            Console.WriteLine("Completed");
            userInputOutput.PrintOutput(outputs);

            Console.WriteLine("Completed");
            Console.ReadLine();
        }
        public void CalculateMaxCyclesTest()
        {
            Input myInput = new Input
            {
                Start = 1,
                End = 10
            };
            long output = 20;
            IChallengeCalculator myComp = new Computer();
            long actual = myComp.CalculateMaxCycles(myInput);

            Assert.AreEqual(output, actual);

        }