Exemplo n.º 1
0
        public long Calculate(List <string> input)
        {
            var bags = input.Select(l => new Bag(l)).ToList();

            return(Bag.GetBag(Bag.ShinyGoldName, bags).CalculateBags(bags));
        }
Exemplo n.º 2
0
        private static void Part1(Bag gold)
        {
            int answer = gold.EnumerateParents().Select(p => p.Color).Distinct().Count();

            Console.WriteLine($"Part 1: {answer}");
        }
Exemplo n.º 3
0
 public void addBag(Bag bag, int amount)
 {
     containedBags.Add(bag, amount);
 }
Exemplo n.º 4
0
        private static void Part2(Bag gold)
        {
            int answer = gold.EnumerateChildren().Sum(c => c.Item1 * c.Item3);

            Console.WriteLine($"Part 2: {answer}");
        }
Exemplo n.º 5
0
 private void AddBag(Bag bag)
 {
     queue.Add(bag);
     numberOfBags++;
     usedBags += $"{bag.Name}, ";
 }