Пример #1
0
        public void TestCreateRuleBook()
        {
            string[] rawData = LuggageProcessor.GetInputData(FilePathTestData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);

            Assert.AreEqual(9, ruleBook.Keys.Count);
        }
Пример #2
0
        public void FindAnserDaySevenPuzzleTwo()
        {
            string[] rawData = LuggageProcessor.GetInputData(FilePathInputData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);

            Assert.Warn("Not solved");
        }
Пример #3
0
        public void TestCountBagOptions(string bagColor, int exptectedOptions)
        {
            string[] rawData = LuggageProcessor.GetInputData(FilePathTestData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);
            int numberOfBagOptions = LuggageProcessor.CountBagOptions(ruleBook, bagColor);

            Assert.AreEqual(exptectedOptions, numberOfBagOptions);
        }
Пример #4
0
        public void TestGetBagOptionsContains()
        {
            string[] rawData = LuggageProcessor.GetInputData(FilePathTestData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);
            List <string> bagOptions = LuggageProcessor.GetBagOptions(ruleBook, "not existing");

            Assert.IsEmpty(bagOptions);
        }
Пример #5
0
        public void TestGetBagOptionsContains(string bagColor, string expectedColor)
        {
            string[] rawData = LuggageProcessor.GetInputData(FilePathTestData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);
            List <string> bagOptions = LuggageProcessor.GetBagOptions(ruleBook, bagColor);

            Assert.Contains(expectedColor, bagOptions);
        }
Пример #6
0
        public void FindAnserDaySevenPuzzleOne()
        {
            string[] rawData = LuggageProcessor.GetInputData(FilePathInputData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);
            int numberOfBagOptions = LuggageProcessor.CountBagOptions(ruleBook, "shiny gold");

            Console.WriteLine("Number of bag options: " + numberOfBagOptions);
            Assert.AreEqual(224, numberOfBagOptions);
        }
Пример #7
0
        public int SolvePart2(IEnumerable <string> input, string bag)
        {
            LuggageProcessor graph = new LuggageProcessor();

            foreach (var line in input)
            {
                graph.ParseInput(line);
            }
            return(graph.GetBag(bag).GetAllContents().Values.Sum());
        }
Пример #8
0
        public int SolvePart1(IEnumerable <string> input, string bag)
        {
            LuggageProcessor graph = new LuggageProcessor();

            foreach (var line in input)
            {
                graph.ParseInput(line);
            }
            return(graph.GetBag(bag).Containers.Count());
        }
Пример #9
0
        public void TestParseLuggageRule(int iTestData, string colorKey, string[] colorValues)
        {
            Dictionary <string, string[]> expectedAnswer = new Dictionary <string, string[]>();

            expectedAnswer[colorKey] = colorValues;

            string[] rawData = LuggageProcessor.GetInputData(FilePathTestData);
            Dictionary <string, string[]> parsedRule = LuggageProcessor.ParseLuggageRule(rawData[iTestData]);

            Assert.AreEqual(expectedAnswer, parsedRule);
        }
Пример #10
0
        public void TestGetBagOptionsEquality()
        {
            var expectedColors = new List <string> {
                "bright white", "muted yellow", "dark orange", "light red"
            };

            string[] rawData = LuggageProcessor.GetInputData(FilePathTestData);
            Dictionary <string, string[]> ruleBook = LuggageProcessor.CreateRuleBook(rawData);
            List <string> bagOptions = LuggageProcessor.GetBagOptions(ruleBook, "shiny gold");

            Assert.Warn("Not solved");

            // Assert.AreEqual(expectedColors, bagOptions);
        }
Пример #11
0
        public void AddContents(string contents, LuggageProcessor graph)
        {
            var items = contents.Split(", ");

            foreach (var item in items)
            {
                var space    = item.IndexOf(' ');
                var end      = item.IndexOf(" bag", space);
                var quantity = Int32.Parse(item.Substring(0, space));
                var bag      = graph.GetBag(item.Substring(space + 1, end - (space + 1)));
                bag.AddContainer(this);
                bag.AddContainers(Containers);
                Contents.Add(bag, quantity);
            }
        }
Пример #12
0
 public void TestGetInputData()
 {
     string[] groupAnswers = LuggageProcessor.GetInputData(FilePathTestData);
     Assert.AreEqual(9, groupAnswers.GetLength(0));
 }