Example #1
0
        static Object PartB()
        {
            List <string>          input = ReadInputs.ReadStrings(inputPath);
            int                    ans   = 0;
            Dictionary <char, int> dict  = new Dictionary <char, int>();
            int                    n     = 0;

            foreach (string s in input)
            {
                if (s == "")
                {
                    ans += dict.Where(x => x.Value == n).Count();
                    dict = new Dictionary <char, int>();
                    n    = 0;
                }
                else
                {
                    foreach (char c in s)
                    {
                        if (!dict.ContainsKey(c))
                        {
                            dict[c] = 0;
                        }
                        dict[c]++;
                    }
                    n++;
                }
            }
            Console.WriteLine("Part B: Result is {0}", ans);
            return(ans);
        }
Example #2
0
        static Object PartB()
        {
            List <string> input = ReadInputs.ReadStrings(inputPath);
            HashSet <int> ids   = GetIds(input);
            int           ans   = ids.Where(x => !ids.Contains(x + 1) && ids.Contains(x + 2)).Min() + 1;

            Console.WriteLine("Part B: Result is {0}", ans);
            return(ans);
        }
Example #3
0
        static Object PartA()
        {
            List <string> input = ReadInputs.ReadStrings(inputPath);
            HashSet <int> ids   = GetIds(input);
            int           ans   = ids.Max();

            Console.WriteLine("Part A: Result is {0}", ans);
            return(ans);
        }
Example #4
0
        static Object PartB()
        {
            List <string> input = ReadInputs.ReadStrings(inputPath);
            int           a     = 0;
            long          ans   = calcTrees(input, 1, 1);

            ans *= calcTrees(input, 1, 3);
            ans *= calcTrees(input, 1, 5);
            ans *= calcTrees(input, 1, 7);
            ans *= calcTrees(input, 2, 1);
            Console.WriteLine("Part B: Result is {0}", ans);
            return(ans);
        }
Example #5
0
        static Object PartA()
        {
            List <string> input = ReadInputs.ReadStrings(inputPath);
            int           ans   = 0;
            int           c     = 0;

            for (int r = 0; r < input.Count; r++)
            {
                if (input[r][c % input[0].Count()] == '#')
                {
                    ans++;
                }
                c += 3;
            }
            Console.WriteLine("Part A: Result is {0}", ans);
            return(ans);
        }
Example #6
0
        static Object PartA()
        {
            List <string>  input = ReadInputs.ReadStrings(inputPath);
            int            ans   = 0;
            HashSet <char> set   = new HashSet <char>();

            foreach (string s in input)
            {
                if (s == "")
                {
                    ans += set.Count;
                    set  = new HashSet <char>();
                }
                else
                {
                    set.UnionWith(s.ToHashSet());
                }
            }
            ans += set.Count;
            Console.WriteLine("Part A: Result is {0}", ans);
            return(ans);
        }