private static int GetNumberOfRegions(string input) { int [,] grid = new int [128, 128]; int regionIndicator = 1; for (int i = 0; i < 128; i++) { string key = input + "-" + i.ToString(); Utilities.KnotHash knotHash = new Utilities.KnotHash(input); string hash = knotHash.GenerateHash(); string binary = HexToBinary(hash); for (int j = 0; j < 128; j++) { grid [i, j] = binary [j] == '0' ? -1 : 0; } } for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { if (grid [i, j] == 0) { FloodFill(grid, i, j, 0, regionIndicator); regionIndicator++; continue; } } } return(regionIndicator - 1); }
public void PartTwo() { Utilities.KnotHash knotHash = new Utilities.KnotHash(stringInput); string hex = knotHash.GenerateHash(); Console.WriteLine(hex); System.Windows.Clipboard.SetText(hex); }
private static int GetUsedSquares(string input) { int used = 0; for (int i = 0; i < 128; i++) { string key = input + "-" + i.ToString(); Utilities.KnotHash knotHash = new Utilities.KnotHash(input); string hash = knotHash.GenerateHash(); string binary = HexToBinary(hash); used += binary.Count(x => x == '1'); } return(used); }