public void Test1() { var input = new[] { new[] { '.', '.', '.', '1', '4', '.', '.', '2', '.' }, new[] { '.', '.', '6', '.', '.', '.', '.', '.', '.' }, new[] { '.', '.', '.', '.', '.', '.', '.', '.', '.' }, new[] { '.', '.', '1', '.', '.', '.', '.', '.', '.' }, new[] { '.', '6', '7', '.', '.', '.', '.', '.', '9' }, new[] { '.', '.', '.', '.', '.', '.', '8', '1', '.' }, new[] { '.', '3', '.', '.', '.', '.', '.', '.', '6' }, new[] { '.', '.', '.', '.', '.', '7', '.', '.', '.' }, new[] { '.', '.', '.', '5', '.', '.', '.', '7', '.' }, }; var result = Sudoku2.sudoku2(input); Assert.IsTrue(result); }
public void sudoku2Test() { var s = new Sudoku2(); Func <string, char> parse = char.Parse; var grid = Util.ParseJaggedArray(@"[[.,.,.,1,4,.,.,2,.], [.,.,6,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,1,.,.,.,.,.,.], [.,6,7,.,.,.,.,.,9], [.,.,.,.,.,.,8,1,.], [.,3,.,.,.,.,.,.,6], [.,.,.,.,.,7,.,.,.], [.,.,.,5,.,.,.,7,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,2,.,.,9,.], [.,.,.,.,6,.,.,.,.], [7,1,.,.,7,5,.,.,.], [.,7,.,.,.,.,.,.,.], [.,.,.,.,8,3,.,.,.], [.,.,8,.,.,7,.,6,.], [.,.,.,.,.,2,.,.,.], [.,1,.,2,.,.,.,.,.], [.,2,.,.,3,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,4,.,.,.,6,3,.], [.,.,.,.,.,.,.,.,.], [5,.,.,.,.,.,.,9,.], [.,.,.,5,6,.,.,.,.], [4,.,3,.,.,.,.,.,1], [.,.,.,7,.,.,.,.,.], [.,.,.,5,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,.,.,2], [.,.,.,.,.,.,6,.,.], [.,.,1,4,.,.,8,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,3,.,.,.,.], [5,.,8,6,.,.,.,.,.], [.,9,.,.,.,.,4,.,.], [.,.,.,.,5,.,.,.,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,9,.,.,4,.,.,.,.], [1,.,.,.,.,.,6,.,.], [.,.,3,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,7,.,.,.,.,.], [3,.,.,.,5,.,.,.,.], [.,.,7,.,.,4,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,7,.,.,.,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[7,.,.,.,4,.,.,.,.], [.,.,.,8,6,5,.,.,.], [.,1,.,2,.,.,.,.,.], [.,.,.,.,.,9,.,.,.], [.,.,.,.,5,.,5,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,2,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,4,.,.,.,.,.,.,.], [.,.,4,.,.,.,.,.,.], [.,.,.,1,.,.,7,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,3,.,.,.,6,.], [.,.,.,.,.,6,.,9,.], [.,.,.,.,1,.,.,.,.], [.,.,.,.,.,.,2,.,.], [.,.,.,8,.,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,5,.,.,.,.,.,.], [.,.,.,8,.,.,.,3,.], [.,5,.,.,2,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,9], [.,.,.,.,.,.,4,.,.], [.,.,.,.,.,.,.,.,7], [.,1,.,.,.,.,.,.,.], [2,4,.,.,.,.,9,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,9,.,.,.,.,.,.,1], [8,.,.,.,.,.,.,.,.], [.,9,9,3,5,7,.,.,.], [.,.,.,.,.,.,.,4,.], [.,.,.,8,.,.,.,.,.], [.,1,.,.,.,.,4,.,9], [.,.,.,5,.,4,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,2,.,.,6,.,.], [.,.,.,1,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,5,.,1,.,.,8], [.,3,.,.,.,.,.,.,.], [.,.,.,9,.,.,.,.,3], [4,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,3,8,.], [.,.,.,.,.,.,.,.,4]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,8,.,.,.,.], [.,.,.,.,.,.,5,.,.], [.,.,.,.,4,.,.,2,.], [.,.,.,3,.,9,.,.,.], [.,.,1,8,.,.,9,.,.], [.,.,.,.,.,5,1,.,.], [.,.,3,.,.,8,.,.,.], [.,1,2,.,3,.,.,.,.], [.,.,.,.,.,7,.,.,1]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,5,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [9,3,.,.,2,.,4,.,.], [.,.,7,.,.,.,3,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,3,4,.,.,.,.], [.,.,.,.,.,3,.,.,.], [.,.,.,.,.,5,2,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,4,.,9,.,.], [.,.,2,1,.,.,3,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,3], [.,.,.,2,.,.,.,.,.], [.,.,.,.,.,7,.,.,.], [.,.,.,6,1,.,.,.,.], [.,.,9,.,.,.,.,.,.], [.,.,.,.,.,.,.,9,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,8,7,6,5,4,3,2,1], [2,.,.,.,.,.,.,.,.], [3,.,.,.,.,.,.,.,.], [4,.,.,.,.,.,.,.,.], [5,.,.,.,.,.,.,.,.], [6,.,.,.,.,.,.,.,.], [7,.,.,.,.,.,.,.,.], [8,.,.,.,.,.,.,.,.], [9,.,.,.,.,.,.,.,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,.,.,.], [4,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,6,.,.], [.,.,.,3,8,.,.,.,.], [.,5,.,.,.,6,.,.,1], [8,.,.,.,.,.,.,6,.], [.,.,.,.,.,.,.,.,.], [.,.,7,.,9,.,.,.,.], [.,.,.,6,.,.,.,.,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,.,.,1], [.,.,.,.,.,6,.,.,.], [4,.,.,.,.,.,3,8,.], [7,.,.,.,.,.,.,.,.], [.,.,.,.,5,3,.,.,.], [.,.,.,.,6,8,.,.,.], [3,.,.,9,.,.,.,.,.], [.,.,.,.,.,2,1,1,.], [.,.,.,.,.,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,8,.,.,.,.,.,.,.], [.,.,.,.,2,.,.,.,.], [.,6,.,.,.,.,1,.,4], [.,.,.,9,.,.,7,.,.], [.,.,.,.,.,.,.,4,.], [.,.,1,.,.,8,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,5,.,7,.], [.,.,3,.,.,5,6,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,.,.,.], [.,.,2,.,.,.,.,.,.], [.,.,.,.,.,2,7,1,.], [.,.,.,.,.,.,.,.,.], [.,2,.,.,.,.,.,.,.], [.,5,.,.,.,.,.,.,.], [.,.,.,.,9,.,.,.,8], [.,.,.,.,.,1,6,.,.], [.,.,.,.,6,.,.,.,.]]", parse); Assert.IsTrue(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,9,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,3,.,.,.,.,.,1], [.,.,.,.,.,.,.,.,.], [1,.,.,.,.,.,3,.,.], [.,.,.,.,2,.,6,.,.], [.,9,.,.,.,.,.,7,.], [.,.,.,.,.,.,.,.,.], [8,.,.,8,.,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); grid = Util.ParseJaggedArray(@"[[.,.,.,.,.,.,8,3,.], [2,.,.,.,.,.,.,.,.], [7,.,.,.,.,7,.,9,5], [.,.,.,1,.,.,.,.,2], [.,8,.,9,.,.,.,.,.], [.,.,5,1,9,.,.,.,.], [5,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.], [.,.,.,.,.,.,.,.,.]]", parse); Assert.IsFalse(s.sudoku2(grid)); }