Exemple #1
0
        public long Part1(int preamble = 25)
        {
            Queue <long> queue = new Queue <long>(25);
            SetSearcher  ss    = new SetSearcher();
            int          i;

            for (i = 0; i < preamble; i++)
            {
                queue.Enqueue(_lines[i]);
            }
            for ( ; i < _lines.Count; i++)
            {
                Tuple <long, long> found = ss.HashSetFind(queue.ToList(), _lines[i]);
                if (found == null)
                {
                    break;
                }
                else
                {
                    queue.Enqueue(_lines[i]);
                    queue.Dequeue();
                }
            }
            return(i < _lines.Count ? _lines[i] : -1);
        }
Exemple #2
0
        static void Day1()
        {
            SetSearcher s = new SetSearcher("inputs/d1p1.txt");

            Console.WriteLine($"Day 1 Part 1: {s.Part1()}");
            // Console.WriteLine($"Day 1 Part 1: {s.Part1Original()}");
            Console.WriteLine($"Day 1 Part 2: {s.Part2()}");
        }