コード例 #1
0
        public void SnailNumber_AddList_ok(string testfile, string expected)
        {
            var         lines = Utils.ReadLinesFromFile(testfile);
            SnailNumber snacc = SnailNumber.Builder(lines[0]);

            for (int i = 1; i < lines.Length; i++)
            {
                SnailNumber sn = SnailNumber.Builder(lines[i]);
                snacc = snacc.Add(sn);
                snacc.Reduce();
            }
            Assert.Equal(expected, snacc.ToString());
        }
コード例 #2
0
        public void SnailNumber_ListMagnitude_OK()
        {
            var         lines = Utils.ReadLinesFromFile("Day18Test5.txt");
            SnailNumber snacc = SnailNumber.Builder(lines[0]);

            for (int i = 1; i < lines.Length; i++)
            {
                SnailNumber sn = SnailNumber.Builder(lines[i]);
                snacc = snacc.Add(sn);
                snacc.Reduce();
            }
            long actual = snacc.Magnitude();

            Assert.Equal(4140, actual);
        }
コード例 #3
0
        public void Day18_Puzzle1_OK()
        {
            var lines = Utils.ReadLinesFromFile("Day18.txt");

            Assert.Equal(100, lines.Length);
            SnailNumber snacc = SnailNumber.Builder(lines[0]);

            for (int i = 1; i < lines.Length; i++)
            {
                SnailNumber sn = SnailNumber.Builder(lines[i]);
                snacc = snacc.Add(sn);
                snacc.Reduce();
            }
            long actual = snacc.Magnitude();

            Assert.Equal(4088, actual);
        }