public void SnailNumber_Parse_OK(string expected)
        {
            SnailNumber sn = SnailNumber.Builder(expected);

            string actual = sn.ToString();

            Assert.Equal(expected, actual);
        }
        public void SnailNumber_ReduceExplode_OK(string lna, string exploding, string expected)
        {
            var sna = SnailNumber.Builder(lna);

            SnailNumber explode = sna.FindExplode(0);

            Assert.Equal(exploding, explode.ToString());

            var sn = sna.Explode();

            Assert.Equal(exploding, sn.ToString());
            Assert.Equal(expected, sna.ToString());
        }
        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());
        }
Exemplo n.º 4
0
 public SnailNumber Add(SnailNumber other)
 {
     return(new SnailNumber($"[{this.ToString()},{other.ToString()}]").Reduce());
 }