def run_tests_row0():
    """ row 0 test runner """

    base = Puzzle(4, 5, [[1, 5, 6, 0, 4], [7, 3, 2, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, (0, 3), "row0 lower half left")

    obj = base.clone()
    obj.set_number(0, 1, 3)
    obj.set_number(1, 1, 5)
    run_test(obj, (0, 3), "row0 upper half left")

    obj = base.clone()
    obj.set_number(1, 2, 3)
    obj.set_number(1, 1, 2)
    run_test(obj, (0, 3), "row0 diagonal")

    obj = base.clone()
    obj.set_number(1, 0, 3)
    obj.set_number(1, 1, 7)
    run_test(obj, (0, 3), "row0 lower left")

    obj = base.clone()
    obj.set_number(0, 0, 3)
    obj.set_number(1, 1, 1)
    run_test(obj, (0, 3), "row0 upper left")

    obj = Puzzle(4, 5, [[1, 2, 0, 3, 4], [6, 5, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]])
    obj.solve_row0_tile(2)
def run_tests_col0():
    """ column 0 test runner """

    base = Puzzle(4, 5, [[10, 6, 5, 4, 3], [2, 1, 8, 9, 7], [0, 11, 12, 13, 14], [15, 16, 17, 18, 19]])

    obj = base.clone()
    obj.set_number(1, 0, 10)
    obj.set_number(0, 0, 2)
    run_test(obj, (2, 0), "col0 short path")

    obj = base.clone()
    run_test(obj, (2, 0), "col0 upper left")

    obj = base.clone()
    obj.set_number(0, 4, 10)
    obj.set_number(0, 0, 3)
    run_test(obj, (2, 0), "col0 upper right")

    obj = base.clone()
    obj.set_number(1, 2, 10)
    obj.set_number(0, 0, 8)
    run_test(obj, (2, 0), "col0 half right")

    obj = base.clone()
    obj.set_number(1, 1, 10)
    obj.set_number(0, 0, 1)
    run_test(obj, (2, 0), "col0 diagonal")
def run_tests_row1():
    """ row 1 test runner """

    base = Puzzle(4, 5, [[9, 4, 6, 5, 1], [7, 3, 8, 2, 0], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, (1, 4), "row1 upper left")

    base = Puzzle(4, 5, [[4, 7, 2, 6, 9], [5, 3, 8, 1, 0], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]])
    obj = base.clone()
    run_test(obj, (1, 4), "row1 upper right")

    obj = base.clone()
    obj.set_number(1, 0, 9)
    obj.set_number(0, 0, 7)
    run_test(obj, (1, 4), "row1 lower left")

    obj = base.clone()
    obj.set_number(1, 4, 9)
    obj.set_number(1, 3, 0)
    obj.set_number(0, 0, 2)
    obj.set_number(0, 4, 4)
    obj.set_number(0, 1, 1)
    run_test(obj, (1, 3), "row1 lower half left")

    obj = base.clone()
    obj.set_number(1, 4, 9)
    obj.set_number(1, 3, 0)
    obj.set_number(1, 2, 6)
    obj.set_number(0, 2, 8)
    obj.set_number(0, 4, 4)
    obj.set_number(0, 1, 1)
    run_test(obj, (1, 3), "row1 upper half left")
def run_tests_col0():
    """ column 0 test runner """

    base = Puzzle(4, 5, [[10, 6, 5, 4, 3], 
                          [2, 1, 8, 9, 7], 
                          [0, 11, 12, 13, 14], 
                          [15, 16, 17, 18, 19]])

    obj = base.clone()
    obj.set_number(1,0, 10)
    obj.set_number(0,0, 2)
    run_test(obj, (2,0), "col0 short path")

    obj = base.clone()
    run_test(obj, (2,0), "col0 upper left")

    obj = base.clone()
    obj.set_number(0,4, 10)
    obj.set_number(0,0, 3)
    run_test(obj, (2,0), "col0 upper right")

    obj = base.clone()
    obj.set_number(1,2, 10)
    obj.set_number(0,0, 8)
    run_test(obj, (2,0), "col0 half right")

    obj = base.clone()
    obj.set_number(1,1,  10)
    obj.set_number(0,0, 1)
    run_test(obj, (2,0), "col0 diagonal")
def run_tests_2x2():
    """ 2x2 test runner """

    base = Puzzle(4, 5, [[1, 6, 2, 3, 4], [5, 0, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, None, "2x2 #1")

    obj = base.clone()
    obj.set_number(0, 0, 6)
    obj.set_number(0, 1, 5)
    obj.set_number(1, 0, 1)
    obj.set_number(1, 1, 0)
    run_test(obj, None, "2x2 #2")

    base = Puzzle(3, 3, [[4, 3, 2], [1, 0, 5], [6, 7, 8]])

    obj = base.clone()
    run_test(obj, None, "2x2 #3")
def run_tests_2x2():
    """ 2x2 test runner """

    base = Puzzle(4, 5, [[1, 6, 2, 3, 4], 
                        [5, 0, 7, 8, 9], 
                        [10, 11, 12, 13, 14], 
                        [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, None, "2x2 #1")

    obj = base.clone()
    obj.set_number(0,0, 6)
    obj.set_number(0,1, 5)
    obj.set_number(1,0, 1)
    obj.set_number(1,1, 0)
    run_test(obj, None, "2x2 #2")
    
    base = Puzzle(3, 3, [[4, 3, 2], [1, 0, 5], [6, 7, 8]])
    
    obj = base.clone()
    run_test(obj, None, "2x2 #3")
def run_tests_row1():
    """ row 1 test runner """

    base = Puzzle(4, 5, [[9, 4, 6, 5, 1], 
                         [7, 3, 8, 2, 0], 
                         [10, 11, 12, 13, 14],
                         [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, (1,4), "row1 upper left")

    base = Puzzle(4, 5, [[4,7,2,6,9],
                         [5,3,8,1,0],
                         [10,11,12,13,14],
                         [15,16,17,18,19]])
    obj = base.clone()
    run_test(obj, (1,4), "row1 upper right")
    
    obj = base.clone()
    obj.set_number(1,0, 9)
    obj.set_number(0,0, 7)
    run_test(obj, (1,4), "row1 lower left")

    obj = base.clone()
    obj.set_number(1,4, 9)
    obj.set_number(1,3, 0)
    obj.set_number(0,0, 2)
    obj.set_number(0,4, 4)
    obj.set_number(0,1, 1)
    run_test(obj, (1,3), "row1 lower half left")

    obj = base.clone()
    obj.set_number(1,4, 9)
    obj.set_number(1,3, 0)
    obj.set_number(1,2, 6)
    obj.set_number(0,2, 8)
    obj.set_number(0,4, 4)
    obj.set_number(0,1, 1)
    run_test(obj, (1,3), "row1 upper half left")
def run_tests_row0():
    """ row 0 test runner """

    base = Puzzle(4, 5, [[1, 5, 6, 0, 4], 
                         [7, 3, 2, 8, 9], 
                         [10, 11, 12, 13, 14],
                         [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, (0,3), "row0 lower half left")

    obj = base.clone()
    obj.set_number(0,1, 3)
    obj.set_number(1,1, 5)
    run_test(obj, (0,3), "row0 upper half left")

    obj = base.clone()
    obj.set_number(1,2, 3)
    obj.set_number(1,1, 2)
    run_test(obj, (0,3), "row0 diagonal")

    obj = base.clone()
    obj.set_number(1,0, 3)
    obj.set_number(1,1, 7)
    run_test(obj, (0,3), "row0 lower left")

    obj = base.clone()
    obj.set_number(0,0, 3)
    obj.set_number(1,1, 1)
    run_test(obj, (0,3),"row0 upper left")

    obj = Puzzle(4, 5, [[1, 2, 0, 3, 4], 
                        [6, 5, 7, 8, 9], 
                        [10, 11, 12, 13, 14], 
                        [15, 16, 17, 18, 19]])
    obj.solve_row0_tile(2)
def run_tests_interior():
    """ interior test runner """

    base = Puzzle(4, 5, [[10, 11, 12, 9, 8], 
                         [7, 6, 5, 4, 3], 
                         [2, 1, 0, 13, 14], 
                         [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, (2,2), "interior same col")

    obj = base.clone()
    obj.set_number(1,1, 12)
    obj.set_number(0,2, 6)
    run_test(obj, (2,2), "interior half left")

    obj = base.clone()
    obj.set_number(1,3, 12)
    obj.set_number(0,2, 4)
    run_test(obj, (2,2), "interior half right")

    obj = base.clone()
    obj.set_number(0,0, 12)
    obj.set_number(0,2, 10)
    run_test(obj, (2,2), "interior upper left")

    obj = base.clone()
    obj.set_number(0,4, 12)
    obj.set_number(0,2, 8)
    run_test(obj, (2,2), "interior upper right")

    obj = base.clone()
    obj.set_number(2,0, 12)
    obj.set_number(0,2, 2)
    run_test(obj, (2,2), "interior same row")

    obj = base.clone()
    obj.set_number(2,1, 12)
    obj.set_number(0,2, 1)
    run_test(obj, (2,2), "interior short path")
def run_tests_interior():
    """ interior test runner """

    base = Puzzle(4, 5, [[10, 11, 12, 9, 8], [7, 6, 5, 4, 3], [2, 1, 0, 13, 14], [15, 16, 17, 18, 19]])

    obj = base.clone()
    run_test(obj, (2, 2), "interior same col")

    obj = base.clone()
    obj.set_number(1, 1, 12)
    obj.set_number(0, 2, 6)
    run_test(obj, (2, 2), "interior half left")

    obj = base.clone()
    obj.set_number(1, 3, 12)
    obj.set_number(0, 2, 4)
    run_test(obj, (2, 2), "interior half right")

    obj = base.clone()
    obj.set_number(0, 0, 12)
    obj.set_number(0, 2, 10)
    run_test(obj, (2, 2), "interior upper left")

    obj = base.clone()
    obj.set_number(0, 4, 12)
    obj.set_number(0, 2, 8)
    run_test(obj, (2, 2), "interior upper right")

    obj = base.clone()
    obj.set_number(2, 0, 12)
    obj.set_number(0, 2, 2)
    run_test(obj, (2, 2), "interior same row")

    obj = base.clone()
    obj.set_number(2, 1, 12)
    obj.set_number(0, 2, 1)
    run_test(obj, (2, 2), "interior short path")