Exemplo n.º 1
0
        private void Run()
        {
            var values    = CommaSeperatedValues.FromString(_args.GetSequence());
            var sequence  = FrequencyChangeSequence.FromCommaSeperatedValues(values);
            var frequency = Frequency.StartFromZero();

            frequency.Add(sequence);

            Console.WriteLine($"The resulting frequency is {frequency.FrequencyNumber}");
        }
Exemplo n.º 2
0
        public void Case4()
        {
            // Arrange
            var sequenceInput = "-1, -2, -3";
            var result        = -6;

            // Act
            var values    = CommaSeperatedValues.FromString(sequenceInput);
            var sequence  = FrequencyChangeSequence.FromCommaSeperatedValues(values);
            var frequency = Frequency.StartFromZero();

            frequency.Add(sequence);

            // Assert
            Assert.Equal(result, frequency.FrequencyNumber);
        }
Exemplo n.º 3
0
        private void Run()
        {
            var values             = CommaSeperatedValues.FromString(_args.GetSequence());
            var sequence           = FrequencyChangeSequence.FromCommaSeperatedValues(values);
            var frequency          = Frequency.StartFromZero();
            var frequencyFound     = false;
            var allFrequencyValues = new List <int>();

            while (!frequencyFound)
            {
                foreach (var change in sequence.Changes)
                {
                    frequency.Add(change);
                    if (allFrequencyValues.Contains(frequency.FrequencyNumber))
                    {
                        Console.WriteLine($"Found it! {frequency.FrequencyNumber}");
                        frequencyFound = true;
                        break;
                    }

                    allFrequencyValues.Add(frequency.FrequencyNumber);
                }
            }
        }