예제 #1
0
        public int SolutionPart1(int volume, params string[] input)
        {
            var containers = CreateContainersFromInput(input).OrderBy(x => x);

            var finder = new CombinationFinder();

            return(finder.FindCombinationsWithSum(containers, volume).Count());
        }
예제 #2
0
        public int SolutionPart2(int volume, params string[] input)
        {
            var containers = CreateContainersFromInput(input).OrderBy(x => x);

            var finder       = new CombinationFinder();
            var combinations = finder.FindCombinationsWithSum(containers, volume);

            var lowest = combinations.Min(x => x.Count());

            var combinationsWithLowest = combinations.Where(x => x.Count() == lowest);

            return(combinationsWithLowest.Count());
        }
예제 #3
0
            public long GetFrontSeatQE(int compartments)
            {
                var groupweight = _packages.Sum() / compartments;

                var finder = new CombinationFinder();
                var combos = finder.FindCombinationsWithSum(_packages, groupweight);

                var mincount       = combos.Min(x => x.Count());
                var smallestcombos = combos.Where(x => x.Count() == mincount);

                long minQE = long.MaxValue;

                foreach (var c in smallestcombos)
                {
                    var qe = CalculateQE(c);

                    if (qe < minQE)
                    {
                        minQE = qe;
                    }
                }

                return(minQE);
            }