Exemplo n.º 1
0
        public bool Solve(int part = 0)
        {
            string   input    = File.ReadAllText("Day10/input.txt");
            KnotHash knotHash = new KnotHash();

            if (part == 2)
            {
                int[] lengths = (input + "\x11\x1f\x49\x2f\x17").Select(c => (int)c).ToArray();

                for (int round = 0; round < 64; round++)
                {
                    knotHash.HashRound(lengths);
                }

                Console.WriteLine(knotHash.GetDenseHash());
            }
            else
            {
                int[] lengths = input.Split(',').Select(s => int.Parse(s)).ToArray();
                int   result  = knotHash.HashRound(lengths);
                Console.WriteLine(result);
            }

            return(true);
        }