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()); }
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()); }
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); }