Example #1
0
        public void SolveSampleCaseThree()
        {
            Grid grid1 = new Grid(new string[] {
                "1 2 3 4",
                "5 6 7 8",
                "9 10 11 12",
                "13 14 15 16"
            });

            Magician magician = new Magician();

            var result = magician.Resolve(2, grid1, 3, grid1);

            Assert.AreEqual("Volunteer cheated!", result);
        }
Example #2
0
        public void SolveSampleCaseTwo()
        {
            Grid grid1 = new Grid(new string[] {
                "1 2 3 4",
                "5 6 7 8",
                "9 10 11 12",
                "13 14 15 16"
            });

            Magician magician = new Magician();

            var result = magician.Resolve(2, grid1, 2, grid1);

            Assert.AreEqual("Bad magician!", result);
        }
Example #3
0
        public void SolveSampleCaseOne()
        {
            Grid grid1 = new Grid(new string[] {
                "1 2 3 4",
                "5 6 7 8",
                "9 10 11 12",
                "13 14 15 16"
            });

            Grid grid2 = new Grid(new string[] {
                "1 2 5 4",
                "3 11 6 15",
                "9 10 7 12",
                "13 14 8 16"
            });

            Magician magician = new Magician();

            var result = magician.Resolve(2, grid1, 3, grid2);

            Assert.AreEqual(7, result);
        }
Example #4
0
        public static void Main(string[] args)
        {
            string inputname = args[0];
            string outputname = args[1];

            string[] lines = File.ReadAllLines(inputname);

            int ncases = int.Parse(lines[0]);
            IList<string> results = new List<string>();
            Magician magician = new Magician();

            for (int k = 0; k < ncases; k++)
            {
                int nline = k * 10 + 1;

                int nrow1 = int.Parse(lines[nline]);

                Grid grid1 = new Grid(new string[] {
                    lines[nline+1],
                    lines[nline+2],
                    lines[nline+3],
                    lines[nline+4]
                });

                int nrow2 = int.Parse(lines[nline+5]);

                Grid grid2 = new Grid(new string[] {
                    lines[nline+6],
                    lines[nline+7],
                    lines[nline+8],
                    lines[nline+9]
                });

                results.Add(string.Format("Case #{0}: {1}", k + 1, magician.Resolve(nrow1, grid1, nrow2, grid2)));
            }

            File.WriteAllLines(outputname, results.ToArray());
        }