public void Puzzle_21A() { var ai = new AllergenIdentifier { Sets = PuzzleInput.Select(x => new Set(x)).ToList() }; ai.Analyze(); Assert.Equal(2317, ai.CountAllergenFreeIngredientsOccurrences()); }
public void Example_1() { var ai = new AllergenIdentifier { Sets = ExampleInput.Select(x => new Set(x)).ToList() }; ai.Analyze(); Assert.Equal(4, ai.AllergenFreeIngredients.Count); Assert.Equal(5, ai.CountAllergenFreeIngredientsOccurrences()); }
public void Puzzle_21B() { var ai = new AllergenIdentifier { Sets = PuzzleInput.Select(x => new Set(x)).ToList() }; ai.Analyze(); var dangerousIngredients = ai.Sets .SelectMany(x => x.DangerousIngredients) .Distinct() .OrderBy(x => x.Value) .Aggregate("", (c, n) => $"{c},{n.Key}")[1..]; Assert.Equal("kbdgs,sqvv,slkfgq,vgnj,brdd,tpd,csfmb,lrnz", dangerousIngredients); }
public void Example_2() { var ai = new AllergenIdentifier { Sets = ExampleInput.Select(x => new Set(x)).ToList() }; ai.Analyze(); var dangerousIngredients = ai.Sets .SelectMany(x => x.DangerousIngredients) .Distinct() .OrderBy(x => x.Value) .Aggregate("", (c, n) => $"{c},{n.Key}")[1..]; Assert.Equal("mxmxvkd,sqjhc,fvjkl", dangerousIngredients); }