Exemplo n.º 1
0
        public static string KnotHash(string data)
        {
            int[] sparseHash = new int[256];
            for (int i = 0; i < sparseHash.Length; i++)
            {
                sparseHash[i] = i;
            }


            string[] input = data.Split(',');

            List <int> lengths = EncodeInputToASCII(input);

            /* run 64 rounds */
            int currentPosition = 0;
            int skipSize        = 0;

            for (int i = 0; i < 64; i++)
            {
                int[] arrLengths = lengths.ToArray();
                Part1.KnotHash(ref sparseHash, ref arrLengths, skipSize, currentPosition,
                               out currentPosition, out skipSize);
            }

            int[]  denseHash = GenerateDenseHash(sparseHash);
            string hexhash   = "";

            foreach (int part in denseHash)
            {
                if (part < 16)
                {
                    hexhash += "0";
                }
                hexhash += part.ToString("x");
            }
            return(hexhash);
        }
Exemplo n.º 2
0
 public static int Solve() => SimulateLaser(Part1.Parse(Data.Map), (27, 19)).Skip(199).FirstOrDefault().Comprise();