Example #1
0
        public override string Solve(string input, int part)
        {
            KnotHash knotHash = new KnotHash(256);

            switch (part)
            {
            case 1:
                knotHash.InitializeWeak(input);
                return("" + knotHash.hash[0] * knotHash.hash[1]);

            case 2:
                knotHash.InitializeStrong(input);
                return(knotHash.ToHexString());
            }

            return(String.Format("Day 10 part {0} solver not found.", part));
        }
Example #2
0
        public override string Solve(string input, int part)
        {
            List <KnotHash> knotHashes = new List <KnotHash>();

            for (int i = 0; i < 128; i++)
            {
                KnotHash knotHash = new KnotHash(256);
                knotHash.InitializeStrong(input + "-" + i);
                knotHashes.Add(knotHash);
            }

            switch (part)
            {
            case 1: return("" + GetUsedSquares(knotHashes));

            case 2: return("" + GetRegionCount(knotHashes));
            }

            return(String.Format("Day 14 part {0} solver not found.", part));
        }