public static string Part2(int listSize, string input) { var standardAddition = new int[] { 17, 31, 73, 47, 23 }; var lengths = input.Select(c => (int)Convert.ToByte(c)).Concat(standardAddition).ToArray(); var runner = new KnotRunner(listSize, lengths); var denseHash = runner.GetResult(); var hexString = BitConverter.ToString(denseHash.ToArray()); return(hexString.Replace("-", string.Empty)); }
private static Dictionary <ValueTuple <int, int>, Point> GetGrid(string input) { var grid = new Dictionary <ValueTuple <int, int>, Point>(); var standardAddition = new int[] { 17, 31, 73, 47, 23 }; for (int i = 0; i < 128; i++) { var part = input + "-" + i; var lengths = part.Select(c => (int)Convert.ToByte(c)).Concat(standardAddition).ToArray(); var runner = new KnotRunner(256, lengths); var result = runner.GetResult().SelectMany(k => Convert.ToString(k, 2).PadLeft(8, '0').Select(c => c == '0' ? 0 : 1)).ToList(); for (var j = 0; j < result.Count(); j++) { grid.Add(new ValueTuple <int, int>(i, j), new Point(i, j, result[j])); } } return(grid); }