Beispiel #1
0
        public void BuildDictionaryTests(string input, byte index, params string[] expected)
        {
            var rules  = new SatelliteRules(input);
            var values = rules.GetValues(index);

            Assert.Equal(expected, values);
        }
Beispiel #2
0
        public void Example2(string input, int expectedBefore, int expectedAfter)
        {
            var halves   = input.Split(Environment.NewLine + Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
            var rules    = new SatelliteRules(halves[0]);
            var messages = halves[1].Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
            var values   = rules.GetValues().ToList();

            Assert.Equal(expectedBefore, messages.Intersect(values).Count());

            rules[8]  = "42 | 42 8";
            rules[11] = "42 31 | 42 11 31";

            values = rules.GetValues().ToList();

            Assert.Equal(expectedAfter, messages.Intersect(values).Count());
        }
Beispiel #3
0
        public void Example1(string input, string[] messages, int expected)
        {
            var rules     = new SatelliteRules(input);
            var values    = rules.GetValues(0);
            var intersect = messages.Intersect(values);

            Assert.Equal(expected, intersect.Count());
        }
Beispiel #4
0
        public async Task Part1(string filename, int expected)
        {
            var text = await filename.ReadAllTextAsync();

            var halves    = text.Split(Environment.NewLine + Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
            var input     = halves[0];
            var messages  = halves[1].Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
            var rules     = new SatelliteRules(input);
            var values    = rules.GetValues(0);
            var intersect = messages.Intersect(values);

            Assert.Equal(expected, intersect.Count());
        }