예제 #1
0
        static void Main(string[] args)
        {
            KnotHash hash = new KnotHash(Input);

            Console.WriteLine(hash.Hash);
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            int[]    input = new int[] { 70, 66, 255, 2, 48, 0, 54, 48, 80, 141, 244, 254, 160, 108, 1, 41 };
            KnotHash kh    = new KnotHash();

            // Part one
            var result = kh.PerformHashRounds(input, 1, 256);

            Console.WriteLine(result[0] * result[1]);

            // Part two
            Console.WriteLine(kh.GenerateHash("70,66,255,2,48,0,54,48,80,141,244,254,160,108,1,41", 64));
        }
예제 #3
0
        static void Main(string[] args)
        {
            StreamReader file = new StreamReader("input.txt");
            string       stream;

            stream = file.ReadToEnd();
            file.Close();

            KnotHash knotHash = new KnotHash();

            Console.WriteLine(string.Format("Result Part1: {0}", knotHash.GetHashChecksum(stream)));
            Console.WriteLine(string.Format("Result Part2: {0}", knotHash.GetHashString(stream)));
            Console.ReadLine();
        }
예제 #4
0
        public static string HashString(string input)
        {
            int itemCount = 256;

            var ascii  = input.Select(c => (int)c).ToList();
            var suffix = new List <int> {
                17, 31, 73, 47, 23
            };

            ascii.AddRange(suffix);

            var hash   = new KnotHash(itemCount, ascii);
            var result = hash.Part2();

            return(result);
        }
예제 #5
0
        static void Main(string[] args)
        {
            string input = "212,254,178,237,2,0,1,54,167,92,117,125,255,61,159,164";

            int itemCount = 256;
            var lengths   = input.Split(',').Select(l => int.Parse(l)).ToList();
            var hash1     = new KnotHash(itemCount, lengths);
            var answer1   = hash1.Part1();

            Console.WriteLine($"Answer 1: {answer1}");

            var answer2 = KnotHash.HashString(input);

            Console.WriteLine($"Answer 2: {answer2}");

            Console.ReadKey();
        }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("+-------------------------+");
            Console.WriteLine("| Advent of Code - Day 10 |");
            Console.WriteLine("+-------------------------+");

            var testInput  = "97,167,54,178,2,11,209,174,119,248,254,0,255,1,64,190";
            var sparseHash = KnotHash.SparseHash(256, testInput.Split(',').Select(x => int.Parse(x)).ToList());

            Console.WriteLine($"The first two hash numbers of the sparse hash mutiplied is {sparseHash[0] * sparseHash[1]}");

            var denseHash = KnotHash.DenseHash(testInput);

            Console.WriteLine($"The dense hash is {denseHash}");
            Console.WriteLine();

            Console.WriteLine($" - Glædelig jul");
        }
예제 #7
0
파일: Program.cs 프로젝트: yorek/aoc-2017
        static void Main(string[] args)
        {
            Console.WriteLine("SAMPLE");
            var khs = new KnotHash("0,1,2,3,4", "3,4,1,5");

            Console.WriteLine($"Final value: {khs.Execute(1)}");
            Console.WriteLine();

            Console.WriteLine("CHALLENGE - PART 1");
            string inputValues  = string.Join(',', Enumerable.Range(0, 256).ToArray());
            string inputLengths = "106,118,236,1,130,0,235,254,59,205,2,87,129,25,255,118";
            var    khc          = new KnotHash(inputValues, inputLengths);

            Console.WriteLine($"Final value: {khc.Execute(1)}");
            Console.WriteLine();

            Console.WriteLine("CHALLENGE - PART 2");
            //inputLengths = "";
            string inputLengths2 = string.Join(',', Encoding.ASCII.GetBytes(inputLengths)) + ",17,31,73,47,23";
            var    khc2          = new KnotHash(inputValues, inputLengths2);

            Console.WriteLine($"Final value: {khc2.CalculateHash()}");
            Console.WriteLine();
        }