示例#1
0
        public override string Solve()
        {
            var data     = ParserFactory.CreateSingleLineStringParser().GetData();
            var position = 1;
            var floor    = 0;

            foreach (var c in data)
            {
                if (c == ')')
                {
                    floor--;
                }
                else if (c == '(')
                {
                    floor++;
                }

                if (floor == -1)
                {
                    return(position.ToString());
                }

                position++;
            }
            return("Error");
        }
示例#2
0
        public override string Solve()
        {
            var directions = ParserFactory.CreateSingleLineStringParser().GetData();
            var visited    = new HashSet <string>();
            var tracker    = new DeliveryTracker(visited);

            foreach (var direction in directions)
            {
                tracker.Move(direction);
            }
            return(visited.Count.ToString());
        }
示例#3
0
        public override string Solve()
        {
            var input  = ParserFactory.CreateSingleLineStringParser().GetData();
            var number = 0;

            for (;;)
            {
                if (Md5Stringify.GetHexCharacters($"{input}{number}").Take(6).All(c => c == '0'))
                {
                    return(number.ToString());
                }
                number++;
            }
        }
示例#4
0
        public override string Solve()
        {
            var data  = ParserFactory.CreateSingleLineStringParser().GetData();
            var floor = 0;

            foreach (var c in data)
            {
                if (c == ')')
                {
                    floor--;
                }
                else if (c == '(')
                {
                    floor++;
                }
            }
            return(floor.ToString());
        }