Esempio n. 1
0
 public void ParseInputTest_NoCenter()
 {
     Assert.AreEqual(PatternUtil.ParseInput(new HashSet <int>()
     {
         1, 2, 3, 4
     }).Count, 0);
 }
Esempio n. 2
0
        public void ParseInputTest_InvalidCombinations()
        {
            var inputs = new List <HashSet <int> >()
            {
                new HashSet <int>()
                {
                    1, 3, 5
                },
                new HashSet <int>()
                {
                    2, 4, 5
                },
                new HashSet <int>()
                {
                    6, 8, 5
                },
                new HashSet <int>()
                {
                    1, 3, 9, 5
                },
            };

            for (int i = 0; i < inputs.Count; i++)
            {
                var input  = inputs[i];
                var result = PatternUtil.ParseInput(input);
                Assert.AreEqual(result.Count, 0);
            }
        }
Esempio n. 3
0
        public void ParseInputTest_MultiplePieces()
        {
            var inputs = new List <HashSet <int> >()
            {
                new HashSet <int>()
                {
                    1, 2, 3, 5
                },
                new HashSet <int>()
                {
                    1, 2, 4, 5
                },
                new HashSet <int>()
                {
                    1, 2, 5, 8, 9
                },
                new HashSet <int>()
                {
                    1, 2, 6, 7, 5
                },
            };
            var expects = new List <List <Pattern> >()
            {
                new List <Pattern> {
                    Pattern.A, Pattern.E
                },
                new List <Pattern> {
                    Pattern.A, Pattern.B
                },
                new List <Pattern> {
                    Pattern.A, Pattern.H
                },
                new List <Pattern> {
                    Pattern.A
                },
            };

            for (int i = 0; i < inputs.Count; i++)
            {
                var input  = inputs[i];
                var expect = expects[i];

                var result = PatternUtil.ParseInput(input);
                Assert.AreEqual(result.Count, expect.Count);
                Assert.IsTrue(expect.All(item => result.Contains(item)));
            }
        }
Esempio n. 4
0
        public void ParseInputTest_SinglePiece()
        {
            var inputs = new List <HashSet <int> >()
            {
                new HashSet <int>()
                {
                    1, 2, 5
                },
                new HashSet <int>()
                {
                    2, 3, 5
                },
                new HashSet <int>()
                {
                    7, 8, 5
                },
                new HashSet <int>()
                {
                    9, 6, 5
                },
            };
            var expects = new List <Pattern>()
            {
                Pattern.A,
                Pattern.E,
                Pattern.D,
                Pattern.G
            };

            for (int i = 0; i < inputs.Count; i++)
            {
                var input  = inputs[i];
                var expect = expects[i];

                var result = PatternUtil.ParseInput(input);
                Assert.AreEqual(result.Count, 1);
                Assert.IsTrue(result.Contains(expect));
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Executes the input
 /// </summary>
 /// <param name="touchedNodes"></param>
 public void ExecuteInput(HashSet <int> touchedNodes)
 {
     var consumedPatterns = PatternUtil.ParseInput(touchedNodes);
     var consumedSlices   = this.PlayerPizza.ConsumeSlices(consumedPatterns);
 }