Exemple #1
0
        protected override int Part1(string[] input)
        {
            var expenses      = input.Select(int.Parse);
            var expenseLookup = new HashSet <int>(expenses);

            int result = 0;

            foreach (var e1 in expenses)
            {
                var e2 = 2020 - e1;
                if (expenseLookup.Contains(e2) && MathHelper.AreDistinct(e1, e2))
                {
                    result = e1 * e2;
                    break;
                }
            }

            return(result);
        }