コード例 #1
0
        private static string CalculateRow(string input, int rowNumber)
        {
            string key = $"{input}-{rowNumber}";

            string hash = D_10_2_External.KnotHashPartTwo(key);

            StringBuilder binary = new StringBuilder();

            foreach (Char c in hash)
            {
                string bin = Convert.ToString(Convert.ToInt32(c.ToString(), 16), 2);

                if (bin.Length < 4)
                {
                    while (bin.Length < 4)
                    {
                        bin = $"0{bin}";
                    }
                }

                binary.Append(bin);
            }

            return(binary.ToString());
        }
コード例 #2
0
        public static bool[,] GenerateGrid(string input)
        {
            var diskBits = new bool[128, 128];

            for (int row = 0; row < 128; row++)
            {
                var hash     = D_10_2_External.KnotHashPartTwo($"{input}-{row}");
                var hashBits = hash.HexToBinary();

                for (var col = 0; col < 128; col++)
                {
                    diskBits[row, col] = hashBits[col] == '1';
                }
            }

            return(diskBits);
        }