public void SolveTest2()
        {
            var solver = new Solver();
            var crossword = new MatrixCrossword(2, new[] { ".*", ".*", "(a|b)+", "b+" }, new[] { "[^a]+", "(aa|bb)*", "a+b+", "(a|b)*" });

            bool solved = solver.Solve(crossword);
            Assert.IsTrue(solved);
            Assert.IsTrue(crossword.IsSolved(), "Crossword has not been solved");
        }
        public void SolveTest3()
        {
            var solver = new Solver();
            var crossword = new MatrixCrossword(2, new[] { "he|ll|o+", "[please]+" }, new[] { "[^speak]+", "ep|ip|ef" });

            bool solved = solver.Solve(crossword);
            Assert.IsTrue(solved);
            Assert.IsTrue(crossword.IsSolved(), "Crossword has not been solved");
        }
        public void SolveTest6()
        {
            var solver = new Solver();

            var crossword = new MatrixCrossword(3, new[] { "(t|e|n)*", @"(.)*w+\1", "[lent]*" }, new[] { "(ent|nte|net)*", "[wear]*", "[r-z]e*[m-r]" });

            bool solved = solver.Solve(crossword);
            Assert.IsTrue(solved);
            Assert.IsTrue(crossword.IsSolved(), "Crossword has not been solved");
        }
        public void SolveTest4()
        {
            var solver = new Solver();

            var crossword = new MatrixCrossword(2, new[] { ".*m?o.*", "(an|fe|be)" }, new[] { @"(a|b|c)\1", "(ab|oe|sk)" });

            bool solved = solver.Solve(crossword);
            Assert.IsTrue(solved);
            Assert.IsTrue(crossword.IsSolved(), "Crossword has not been solved");
        }
Exemple #5
0
        static void Main(string[] args)
        {
            var solver = new Solver();
            int size = 6;

            var leftRightExpressions = new[]
                                           {
                                               ".*h.*h.*",
                                               "(di|ns|th|om)*",
                                               "f.*[ao].*[ao].*",
                                               "(o|rhh|mm)*",
                                               ".*",
                                               "c*mc(ccc|mm)*",
                                               "[^c]*[^r]*iii.*",
                                               @"(...?)\1*",
                                               "([^x]|xcc)*",
                                               "(rr|hhh)*.?",
                                               "n.*x.x.x.*e",
                                               "r*d*m*",
                                               ".(c|hh)*"
                                           };
            var bottomTopExpressions = new[]
                                           {
                                               ".*g.*v.*h.*",
                                               "[cr]*",
                                               ".*xexm*",
                                               ".*dd.*ccm.*",
                                               ".*xhcr.*x.*",
                                               @".*(.)(.)(.)(.)\4\3\2\1.*",
                                               ".*(in|se|hi)",
                                               "[^c]*mmm[^c]*",
                                               @".*(.)c\1x\1.*",
                                               "[ceimu]*oh[aemor]*",
                                               "(rx|[^r])*",
                                               "[^m]*m[^m]*",
                                               "(s|mm|hhh)*",
                                           };

            var topBottomExpressions = new[]
                                           {
                                               "(nd|et|in)[^x]*",
                                               "[chmnor]*i[chmnor]*",
                                               @"p+(..)\1.*",
                                               "(e|cr|mn)*",
                                               "([^mc]|mm|cc)*",
                                               "[am]*cm(rc)*r?",
                                               ".*",
                                               ".*prr.*ddc.*",
                                               "(hhx|[^hx])*",
                                               "([^emc]|em)*",
                                               ".*oxr.*",
                                               ".*lr.*rl.*",
                                               ".*se.*ue.*",
                                           };

            var crossword = new HexagonCrossword(size, leftRightExpressions, bottomTopExpressions, topBottomExpressions);
            solver.Solve(crossword);
            Console.WriteLine("Is solved: {0}", crossword.IsSolved());
            crossword.Print();
            Console.WriteLine("Press ENTER to exit");
            Console.ReadLine();
        }