Ejemplo n.º 1
0
        public int CalculateLength(string inputPath)
        {
            var inputText = File.ReadAllText(inputPath);
            var polymer   = new Polymer(inputText.Trim());
            var result    = polymer.React();

            return(result);
        }
Ejemplo n.º 2
0
        public int Reduce(string inputPath)
        {
            var inputText = File.ReadAllText(inputPath);
            var polymers  = new List <int>();

            for (int i = 0; i < 26; i++)
            {
                var char1   = (char)(i + 65);
                var char2   = (char)(char1 + 32);
                var polymer = new Polymer(inputText.Trim(), new [] { char1, char2 });
                polymers.Add(polymer.React());
            }

            var result = polymers.OrderBy(i => i).First();

            return(result);
        }