示例#1
0
文件: Test07.cs 项目: htoomik/aoc2018
        public void Solve1()
        {
            var data   = File.ReadAllLines("C:\\Code\\aoc2018\\aoc2018\\Data\\input07.txt").ToList();
            var result = Day07.Solve1(data);

            _output.WriteLine(result);
        }
示例#2
0
    public static void Y2015_Day07_InstructionsAreInterpretedCorrectly()
    {
        // Arrange
        string[] instructions = new string[]
        {
            "j -> k",
            "123 -> x",
            "456 -> y",
            "x AND y -> d",
            "x OR y -> e",
            "x LSHIFT 2 -> f",
            "y RSHIFT 2 -> g",
            "NOT x -> h",
            "NOT y -> i",
            "i -> j",
        };

        // Act
        IDictionary <string, ushort> actual = Day07.GetWireValues(instructions);

        // Assert
        actual.ShouldNotBeNull();
        actual.ShouldContainKeyAndValue <string, ushort>("d", 72);
        actual.ShouldContainKeyAndValue <string, ushort>("e", 507);
        actual.ShouldContainKeyAndValue <string, ushort>("f", 492);
        actual.ShouldContainKeyAndValue <string, ushort>("g", 114);
        actual.ShouldContainKeyAndValue <string, ushort>("h", 65412);
        actual.ShouldContainKeyAndValue <string, ushort>("i", 65079);
        actual.ShouldContainKeyAndValue <string, ushort>("j", 65079);
        actual.ShouldContainKeyAndValue <string, ushort>("k", 65079);
        actual.ShouldContainKeyAndValue <string, ushort>("x", 123);
        actual.ShouldContainKeyAndValue <string, ushort>("y", 456);
    }
示例#3
0
        public void Part01()
        {
            // Arrange
            var input = new[] {
                "pbga (66)",
                "xhth (57)",
                "ebii (61)",
                "havc (66)",
                "ktlj (57)",
                "fwft (72) -> ktlj, cntj, xhth",
                "qoyq (66)",
                "padx (45) -> pbga, havc, qoyq",
                "tknk (41) -> ugml, padx, fwft",
                "jptl (61)",
                "ugml (68) -> gyxo, ebii, jptl",
                "gyxo (61)",
                "cntj (57)"
            };

            // Act
            string actual = Day07.Part01(input);

            // Assert
            Assert.Equal("tknk", actual);
        }
示例#4
0
        public void Part1_WithExampleInput_ReturnsExpectedAnswer()
        {
            var input  = new[] { 16, 1, 2, 0, 4, 2, 7, 1, 2, 14 };
            var result = Day07.SolvePart1(input);

            Assert.Equal(37, result);
        }
示例#5
0
文件: Test07.cs 项目: htoomik/aoc2018
        public void Solve2()
        {
            var data   = File.ReadAllLines("C:\\Code\\aoc2018\\aoc2018\\Data\\input07.txt").ToList();
            var result = Day07.Solve2(data, 5, 60);

            _output.WriteLine(result.ToString());
        }
示例#6
0
        public void Example1Test()
        {
            var day = new Day07(AdventOfCode2016.Inputs.Day07.testData);

            day.Run();
            Assert.Equal("2", day.GetFirstResult());
        }
示例#7
0
        public void Solve2()
        {
            var input  = InputDataHelper.Get(7);
            var output = new Day07().Solve2(input);

            _testOutputHelper.WriteLine(output.ToString());
        }
示例#8
0
        public void Day07()
        {
            var d = new Day07();

            Assert.AreEqual(326, d.CanContainShinyGoldBagCount());
            Assert.AreEqual(5635, d.BagsInsideShinyGoldBagCount());
        }
示例#9
0
        public void GetDay7Part2AnswerTest()
        {
            int expected = 84088865;
            int actual   = Day07.GetDay7Part2Answer();

            Assert.Equal(expected, actual);
        }
示例#10
0
    public static void Y2018_Day07_Assemble_Returns_Correct_Solution(
        int workers,
        int partDuration,
        string expectedOrder,
        int expectedTime)
    {
        // Arrange
        string[] instructions =
        {
            "Step C must be finished before step A can begin.",
            "Step C must be finished before step F can begin.",
            "Step A must be finished before step B can begin.",
            "Step A must be finished before step D can begin.",
            "Step B must be finished before step E can begin.",
            "Step D must be finished before step E can begin.",
            "Step F must be finished before step E can begin.",
        };

        // Act
        (string actualOrder, int actualTime) = Day07.Assemble(instructions, partDuration, workers);

        // Assert
        actualOrder.ShouldBe(expectedOrder);
        actualTime.ShouldBe(expectedTime);
    }
示例#11
0
        public void GetDay7Part1AnswerTest()
        {
            int expected = 255840;
            int actual   = Day07.GetDay7Part1Answer();

            Assert.Equal(expected, actual);
        }
示例#12
0
        public void Day07Part1()
        {
            var testData = new string[]
            {
                "123 -> x",
                "456 -> y",
                "x AND y -> d",
                "x OR y -> e",
                "x LSHIFT 2 -> f",
                "y RSHIFT 2 -> g",
                "NOT x -> h",
                "NOT y -> i"
            };

            var dict = new Dictionary <string, ushort>();

            foreach (var line in testData)
            {
                Day07.ParseLine(line, dict, "");
            }

            Assert.IsTrue(dict["d"] == 72);
            Assert.IsTrue(dict["e"] == 507);
            Assert.IsTrue(dict["f"] == 492);
            Assert.IsTrue(dict["g"] == 114);
            Assert.IsTrue(dict["h"] == 65412);
            Assert.IsTrue(dict["i"] == 65079);
            Assert.IsTrue(dict["x"] == 123);
            Assert.IsTrue(dict["y"] == 456);
        }
示例#13
0
        public void Day07()
        {
            var d = new Day07("Day07Test.txt");

            Assert.AreEqual(4, d.CanContainShinyGoldBagCount());
            Assert.AreEqual(32, d.BagsInsideShinyGoldBagCount());
        }
示例#14
0
 public void IsSslTest()
 {
     Assert.True(Day07.IsSsl("aba[bab]xyz"));
     Assert.False(Day07.IsSsl("xyx[xyx]xyx"));
     Assert.True(Day07.IsSsl("aaa[kek]eke"));
     Assert.True(Day07.IsSsl("zazbz[bzb]cdb"));
 }
示例#15
0
        public void Day07()
        {
            var day = new Day07();

            Assert.Equal("eqgvf", day.FirstPart());
            Assert.Equal("757", day.SecondPart());
        }
示例#16
0
        public void GetDay07Part02AnswerTest()
        {
            int expected = 30899;
            int actual   = Day07.GetDay07Part02Answer();

            Assert.Equal(expected, actual);
        }
示例#17
0
    public static void Y2017_Day07_FindDesiredWeightOfUnbalancedDisc_Returns_Correct_Value()
    {
        // Arrange
        string[] structure = new[]
        {
            "pbga (66)",
            "xhth (57)",
            "ebii (61)",
            "havc (66)",
            "ktlj (57)",
            "fwft (72) -> ktlj, cntj, xhth",
            "qoyq (66)",
            "padx (45) -> pbga, havc, qoyq",
            "tknk (41) -> ugml, padx, fwft",
            "jptl (61)",
            "ugml (68) -> gyxo, ebii, jptl",
            "gyxo (61)",
            "cntj (57)",
        };

        // Act
        int actual = Day07.FindDesiredWeightOfUnbalancedDisc(structure);

        // Assert
        actual.ShouldBe(60);
    }
示例#18
0
    public static void Y2017_Day07_FindBottomProgramName_Returns_Correct_Value()
    {
        // Arrange
        string[] structure = new[]
        {
            "pbga (66)",
            "xhth (57)",
            "ebii (61)",
            "havc (66)",
            "ktlj (57)",
            "fwft (72) -> ktlj, cntj, xhth",
            "qoyq (66)",
            "padx (45) -> pbga, havc, qoyq",
            "tknk (41) -> ugml, padx, fwft",
            "jptl (61)",
            "ugml (68) -> gyxo, ebii, jptl",
            "gyxo (61)",
            "cntj (57)",
        };

        // Act
        string actual = Day07.FindBottomProgramName(structure);

        // Assert
        actual.ShouldBe("tknk");
    }
示例#19
0
文件: Day07Tests.cs 项目: zawupf/aoc
        public void Stars()
        {
            var run = new Day07();

            Assert.Equal("115", run.Result1());
            Assert.Equal("1250", run.Result2());
        }
示例#20
0
    public static void Y2016_Day07_DoesIPAddressSupportTls_Returns_Correct_Solution(string address, bool expected)
    {
        // Act
        bool actual = Day07.DoesIPAddressSupportTls(address);

        // Assert
        actual.ShouldBe(expected);
    }
示例#21
0
    public void Part2()
    {
        var expected = 168;
        var day      = new Day07();
        var actual   = day.Part2(_input);

        Assert.Equal(expected, actual);
    }
示例#22
0
文件: Test07.cs 项目: htoomik/aoc2020
        public void Solve2()
        {
            var input  = DataHelper.GetAllRows(7);
            var solver = new Day07();
            var result = solver.Solve2(input);

            Output.WriteLine(result.ToString());
        }
示例#23
0
        private static void Main(string[] args)
        {
            var filename = args[0];
            var day07    = new Day07(filename);

            Console.WriteLine(day07.Solve_1());
            Console.WriteLine(day07.Solve_2());
        }
示例#24
0
        public void CanParseInput()
        {
            var day = new Day07();

            day.GetInput(file: "test.txt", pattern: "\r\n");
            day.Level1(day.Input).Should().Be("335");
            day.Level2(day.Input).Should().Be("2431");
        }
示例#25
0
 public void IsTlsTest()
 {
     Assert.True(Day07.IsTls("abba[mnop]qrst"));
     Assert.False(Day07.IsTls("abcd[bddb]xyyx"));
     Assert.False(Day07.IsTls("aaaa[qwer]tyui"));
     Assert.True(Day07.IsTls("ioxxoj[asdfgh]zxcvbn"));
     Assert.True(Day07.IsTls("ipseqmdzbeeqjsnvo[qxgatjiqzhwulhgkjm]syofcufklnbeobppx[lbmkistwoiolecjh]qpznlrllrkhxrnyvf[zbhzvyjqzywdpvh]thlrfwmziexkhxgp"));
 }
示例#26
0
        public void Part2test2( )
        {
            day7 = new Day07("day07test2");
            var expected = 126;
            var actual   = day7.SolvePart2( );

            Assert.AreEqual(expected.ToString( ), actual);
        }
示例#27
0
    public async Task Y2019_Day07_RunProgram_Returns_Correct_Output(string program, bool useFeedback, long expected)
    {
        // Act
        long actual = await Day07.RunProgramAsync(program, useFeedback, CancellationToken.None);

        // Assert
        actual.ShouldBe(expected);
    }
示例#28
0
        public void TestPartB()
        {
            const long answerB = 168;

            var day = new Day07(input);
            var b   = (long)day.PartB();

            Assert.AreEqual(answerB, b);
        }
示例#29
0
        public void CanExtractRule()
        {
            List <Bag> bags       = new List <Bag>();
            var        rulestring = "vibrant aqua bags contain 5 posh plum bags, 5 faded tomato bags, 5 shiny tomato bags, 1 mirrored orange bag.";
            Bag        rule       = Day07.ParseRule(rulestring, bags);

            rule.hasGold.Should().BeFalse();
            rule.containedBags.Count.Should().Be(4);
        }
示例#30
0
        public void TestPartA()
        {
            const long answerA = 37;

            var day = new Day07(input);
            var a   = (long)day.PartA();

            Assert.AreEqual(answerA, a);
        }