Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend #13

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Backend/sudoku.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
None


if __name__ == "__main__":
main()
48 changes: 41 additions & 7 deletions sudoku_generator.py → Backend/sudoku_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class SudokuGenerator:
None
'''
def __init__(self, row_length, removed_cells):
pass
self.row_length = row_length
self.removed_cells = removed_cells
self.board = []
self.box_length = row_length ** 0.5


'''
Returns a 2D python list of numbers which represents the board
Expand All @@ -32,7 +36,7 @@ def __init__(self, row_length, removed_cells):
Return: list[list]
'''
def get_board(self):
pass
return self.board

'''
Displays the board to the console
Expand All @@ -42,7 +46,8 @@ def get_board(self):
Return: None
'''
def print_board(self):
pass
for i in range(self.board):
None

'''
Determines if num is contained in the specified row (horizontal) of the board
Expand All @@ -55,7 +60,11 @@ def print_board(self):
Return: boolean
'''
def valid_in_row(self, row, num):
pass
if num in self.board[row]:
return False
else:
return True


'''
Determines if num is contained in the specified column (vertical) of the board
Expand All @@ -68,7 +77,10 @@ def valid_in_row(self, row, num):
Return: boolean
'''
def valid_in_col(self, col, num):
pass
for row in self.board:
if row[col] == num:
return False
return True

'''
Determines if num is contained in the 3x3 box specified on the board
Expand All @@ -83,7 +95,12 @@ def valid_in_col(self, col, num):
Return: boolean
'''
def valid_in_box(self, row_start, col_start, num):
pass
for i in range(row_start - 1 ,row_start + 2):
for j in range(col_start -1, col_start + 2):
if self.board[i][j] == num:
return False

return True

'''
Determines if it is valid to enter num at (row, col) in the board
Expand All @@ -96,7 +113,24 @@ def valid_in_box(self, row_start, col_start, num):
Return: boolean
'''
def is_valid(self, row, col, num):
pass
if self.valid_in_col(col, num) and self.valid_in_row(row, num):
if row <= 3:
row_start = 1
elif row <=6:
row_start = 4
else:
row_start = 7
if col <= 3:
col_start = 1
elif col <= 6:
col_start = 4
else:
col_start = 7
if self.valid_in_box(row_start, col_start, num):
return True

return False


'''
Fills the specified 3x3 box with values
Expand Down
1 change: 1 addition & 0 deletions Backend/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print(16 ** 0.5)
3 changes: 3 additions & 0 deletions Frontend/board.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Board:
None

2 changes: 2 additions & 0 deletions Frontend/cell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Cell:
None
1 change: 1 addition & 0 deletions Frontend/unicorn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import pygame
30 changes: 30 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
test_board = [
[4, 8, 7, 9, 2, 5, 9, 1, 6],
[1, 8, 7, 6, 6, 9, 2, 7, 2],
[2, 3, 7, 1, 2, 9, 9, 8, 9],
[7, 9, 6, 2, 4, 9, 6, 1, 9],
[2, 1, 1, 4, 9, 5, 5, 7, 6],
[1, 3, 4, 6, 9, 5, 7, 2, 3],
[9, 2, 8, 5, 5, 9, 4, 6, 2],
[6, 5, 9, 3, 3, 6, 9, 9, 8],
[5, 9, 5, 7, 2, 7, 5, 7, 5]
]

row_start = 5
col_start = 1

# Valid in box
# for i in range(row_start - 1 ,row_start + 2):
# for j in range(col_start -1, col_start + 2):
# print(test_board[i][j], end="")
# print()

# for i in test_board:
# print(i[0])

# board = []
# class Test:
# def __init__(self, board):
# self.board = board

# test = Test(test_board)