示例#1
0
文件: Day16.cs 项目: sujithq/aoc
        public string Part2(string input, string baseLIne, int count)
        {
            if (input.IsNullOrEmpty())
            {
                return(string.Empty);
            }

            var rawMoves = input.Split(',').Select(s => s.AsSpan()).ToList();

            var bl = baseLIne.AsSpan();

            var sw = Stopwatch.StartNew();

            for (var i = 0; i < count; i++)
            {
                var dance = new Dance(bl);

                foreach (var rawMove in rawMoves)
                {
                    dance.Step(rawMove);
                }

                if (i % 100 == 0)
                {
                    sw.Stop();
                    TestContext.Progress.WriteLine($"{count - i} - {sw.ElapsedMilliseconds}");
                    sw.Restart();
                }
                bl = dance.BaseLine;
            }

            return(new string(bl.ToArray()));
        }
示例#2
0
文件: Day16.cs 项目: sujithq/aoc
        public string Part1(string input, string baseLIne)
        {
            if (input.IsNullOrEmpty())
            {
                return(string.Empty);
            }

            var rawMoves = input.Split(',').Select(s => s.AsSpan());

            var dance = new Dance(baseLIne);

            foreach (var rawMove in rawMoves)
            {
                dance.Step(rawMove);
            }

            return(dance.Result());
        }