示例#1
0
        public static void Task1()
        {
            Console.WriteLine("AOC2020_Day21_1");

            Foods foods = new Foods();

            foods.Read();
            var alergenes = foods.FindAlergenes();

            var found = new SortedSet <string>();

            foreach (var i in alergenes)
            {
                found.Add(i.Item2);
                Console.WriteLine("{0} - {1}", i.Item1, i.Item2);
            }
            ;

            int tot = 0; int t2 = 0;

            foreach (var food in foods.foods)
            {
                t2 += food.ingredients.Count;
                foreach (var ingr in  food.ingredients)
                {
                    if (!found.Contains(ingr))
                    {
                        tot++;
                    }
                }
            }

            Console.WriteLine("OK Ingrs = {0}", tot);
        }
示例#2
0
        public static void Task2()
        {
            Console.WriteLine("AOC2020_Day21_2");

            Foods foods = new Foods();

            foods.Read();
            var alergenes = foods.FindAlergenes();

            alergenes.Sort((x, y) => {
                return(x.Item1.CompareTo(y.Item1));
            });

            Console.Write("Ret - ");

            foreach (var al in alergenes)
            {
                Console.Write("{0},", al.Item2);
            }
        }