-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.py
More file actions
162 lines (127 loc) · 3.49 KB
/
program.py
File metadata and controls
162 lines (127 loc) · 3.49 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from SudokuGame import SudokuGame
# region Menu functions
def Menu():
print('''
----------- MENU --------------
[0] Exit
[1] Option 1:\tStart a new game [genarate]
[2] Option 2:\tShow datas about table
[3] Option 3:\tPrint table
[4] Option 4:\tPrint table just nums [Every size]
[5] Option 5:\tPrint the original table (just with nums) [Every size]
[6] Option 6:\tSolve sudoku with powershell subprocess
----------------------------------''')
MenuRun()
def MenuRun():
try:
option = int(input("Enter your option: "))
except ValueError as err:
print(err)
MenuRun()
if option == 0:
exit()
while option != 0:
if option == 1:
print("-- option 1 --")
NewGame()
PrintTable()
Menu()
elif option == 2:
print("-- option 2 --")
ShowDatasAboutATable(game1)
Menu()
elif option == 3:
print("-- option 3 --")
PrintTable()
Menu()
elif option == 4:
print("-- option 4 --")
PrintTableJNums()
Menu()
elif option == 5:
print("-- option 5 --")
PrintOrigin()
Menu()
elif option == 6:
print("-- option 6 --")
CallSolverFromPS()
Menu()
else:
print("Invalid option!")
Menu()
print()
def NewGame():
tableS = 4
regionS = 2
diff = 1
try:
diff = int(input('''
Type in difficulty level!
Easy = 1 [default], Medium = 2, Hard = 3 \n'''))
except ValueError or UnboundLocalError as err:
print(err)
if diff not in [1, 2, 3]:
diff = 1
try:
tableS = int(input("Enter TableSize! (4 [default]/9/16/25): \n"))
except ValueError or UnboundLocalError as err:
print(err)
if tableS not in [4, 9, 16, 25]:
tableS = 4
if tableS == 4:
regionS = 2
print("Your regionSize is 2")
elif tableS == 9:
regionS = 3
print("Your regionSize is 3")
elif tableS == 16:
regionS = 4
print("Your regionSize is 4")
elif tableS == 25:
regionS = 5
print("Your regionSize is 5")
else:
print("Bad size")
try:
game1.NewGame(tableS, regionS, diff)
except ValueError or UnboundLocalError as err:
print(err)
def ShowDatasAboutATable(game):
print("--show_datas_about_a_table--")
print("TableSize: " + str(game._table.Size()))
print("RegionsSize: " + str(game._table.RegionSize()))
print("isFilled: " + str(game._table.IsFilled()))
print("Difficulty: " + str(game1._gameDifficulty))
print("-__-")
def PrintTable():
if game1._table.Size() == 4 or game1._table.Size() == 9:
PrintTableJNums()
elif game1._table.Size() == 16:
PrintTableWLetters()
elif game1._table.Size() == 25:
PrintTableJLetters()
else:
print("Error")
def PrintTableWLetters():
game1.PrintTableWithLetters()
def PrintTableJLetters():
game1.PrintTableJustLetters()
def PrintTableJNums():
game1.PrintTableJustNums()
def PrintOrigin():
game1.PrintOriginTable()
def CallSolverFromPS():
game1.CallSolverFromPS()
# endregion
# region Main
print("\t---- Game started ----")
diff = 1 # Easy
try:
game1 = SudokuGame(4, 2, diff)
game1.NewGame(4, 2, diff)
except ValueError as err:
print(err)
exit()
# menu
Menu()
# endregion