예제 #1
0
파일: main.py 프로젝트: drishti307/sudoku
def main():

    ch = input(
        "enter 1 if you want to create custom puzzle, or 2 to solve random 9x9 puzzle: "
    )

    if ch == '2':
        n = 9
        board = board_diff
    elif ch == '1':
        n = int(input("Enter dimensions of board"))
        g = Graph(n)
        board = [[0 for x in range(n)] for y in range(n)]
        while True:
            print("enter row, col, number")
            try:
                x = int(input())
                y = int(input())
                num = int(input())
                if x > n or y > n or num > n:
                    break
                g.AddEdge(x, y, num)

            except Exception as e:
                print(e)
                break

        g.GraphtoBoard(board)
        #print(len(board))
    disp_board(board)

    sl = int(
        input("enter 1 if you want to run backtrack, 2 to run fwd check: "))
    start = time.time()

    if sl == 1:
        soln.sol_fwd_check(board)
    else:
        soln.solve(board)

    end = time.time()

    disp_board(board)
    print(f"Runtime of the program is {end - start}")
예제 #2
0
            if node.left > 20000:
                print '-' * 40, "Something's gone wrong!"
                print "node.layoutPosX, node.layoutPosY", node.layoutPosX, node.layoutPosY
                self.DumpCalibrationInfo(False)
                raise CustomException("Insane x values being generated")


if __name__ == '__main__':

    from graph import Graph, GraphNode

    g = Graph()

    n1 = GraphNode('A', 0, 0, 200, 200)
    n2 = GraphNode('B', 0, 0, 200, 200)
    g.AddEdge(n1, n2)
    """
    coordinate mapper translation tests
    """

    # Force some values
    g.layoutMaxX, g.layoutMinX, g.layoutMaxY, g.layoutMinY = 5.14284838307, -7.11251323652, 4.97268108065, -5.77186339003

    c = CoordinateMapper(g, (784, 739))

    # LayoutToWorld

    res = c.LayoutToWorld((-2.7556504645221258, 0.39995144721675263))
    print res
    assert res[0] == 149, res
    assert res[1] == 221, res