-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.py
31 lines (28 loc) · 1.04 KB
/
board.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import random
import copy
import sudoku_solver as ss
def create_board():
starting_board = [
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1]
]
# randomly fill some values in
for i in range(1, 4):
l = list(range(1, 10))
one_to_three = [1, 2, 3]
filler = random.choice(l)
for j in range(10):
row = random.choice(one_to_three) * i
col = random.choice(one_to_three) * i
while not ss.is_valid_guess(starting_board, filler, row - 1, col - 1):
filler = random.choice(l)
starting_board[row - 1][col - 1] = filler
l.remove(filler)
return starting_board