示例#1
0
        public override string Solve()
        {
            var frequency = 0;

            foreach (var line in _lines)
            {
                frequency += FrequencyParser.ParseChange(line);
            }

            return(frequency.ToString());
        }
示例#2
0
        public override string Solve()
        {
            var frequency          = 0;
            var reachedFrequencies = new HashSet <int>();

            while (true)
            {
                foreach (var line in InputReader.ReadLines())
                {
                    frequency += FrequencyParser.ParseChange(line);
                    if (reachedFrequencies.Contains(frequency))
                    {
                        return(frequency.ToString());
                    }

                    reachedFrequencies.Add(frequency);
                }
            }
        }