コード例 #1
0
def test4():
    sudoku_bt.count = 0
    sudoku_bt.N=10
    map=[
        [10,0,0,0,0,0,0,0,0,0],
        [0,0,3,6,0,0,0,0,0,0],
        [0,7,0,0,9,0,2,0,0,0],
        [0,5,0,0,0,7,0,0,0,0],
        [0,0,0,0,4,5,7,0,0,0],
        [0,0,0,1,0,0,0,3,0,0],
        [0,0,1,0,0,0,0,6,8,0],
        [0,0,8,5,0,0,0,1,0,0],
        [0,9,0,0,0,0,4,0,0,0],
        [0,10,0,0,0,0,0,0,0,0],
    ]

    sudoku_bt.display(map)
    t0=time.time()
    r=sudoku_bt.BT(map, 0, 0)
    t1=time.time()
    
    if r:
        sudoku_bt.display(map)
        print("time: %.3fs" %(t1-t0))
        print("# of recurrence: %d" %(sudoku_bt.count))
    else:
        print("no solutions.")
コード例 #2
0
def test1():
        
    sudoku_bt.count = 0
    sudoku_bt.N=6
    map=[
        [0,1,0,0,0,5], 
        [0,6,0,0,0,2],
        [0,0,0,1,0,4], 
        [0,0,0,2,3,0],
        [4,2,0,0,0,0],
        [0,0,6,0,2,0], 
        ]

    sudoku_bt.display(map)
    t0=time.time()
    r=sudoku_bt.BT(map, 0, 0)
    t1=time.time()
    
    if r:
        sudoku_bt.display(map)
        print("time: %.3fs" %(t1-t0))
        print("# of recurrence: %d" %(sudoku_bt.count))
    else:
        print("no solutions.")