def interface(): number = row = column = selection = static = 0 while selection != "4" and selection != "9": selection = input("What version do you want to play? input 4 or 9: ") while static != "y" and static != "n": static = input("Do you want to play with a static board?: ") if selection == "9": print("Starting Game") print("Rows and Colums go from 1 to 9, not from 0 to 8") game = Sudoku9() if static == "y": game.set_board([[5, 3, "", "", 7, "", "", "", ""], [6, "", "", 1, 9, 5, "", "", ""], ["", 9, 8, "", "", "", "", 6, ""], [8, "", "", "", 6, "", "", "", 3], [4, "", "", 8, "", 3, "", "", 1], [7, "", "", "", 2, "", "", "", 6], ["", 6, "", "", "", "", 2, 8, ""], ["", "", "", 4, 1, 9, "", "", 5], ["", "", "", "", 8, "", "", 7, 9]]) elif static == "n": game.set_board(get_board_from_api(9)) while game.is_playing: board = game.board_print() print(board) number = input("Wich number do you want to place?: ") row = input("Wich ROW: ") column = input("Wich COLUMN: ") game.play(number, row, column) print("Victory") elif selection == "4": print("Starting Game") print("Rows and Colums go from 1 to 4, not from 0 to 3") game = Sudoku4() if static == "y": game.set_board([["", 3, 4, ""], [4, "", "", 2], [1, "", "", 3], ["", 2, 1, ""]]) elif static == "n": game.set_board(get_board_from_api(4)) while game.is_playing: board = game.board_print() print(board) number = input("Wich number do you want to place?: ") row = input("Wich ROW: ") column = input("Wich COLUMN: ") game.play(number, row, column) print("Victory")
def test_board_size_9(self): board = get_board_from_api(9) self.assertEqual(len(board), 9) for column in range(9): self.assertEqual(len(board[column]), 9)
def test_invalid_board_size_string(self): board = get_board_from_api("nine") self.assertEqual(board, "invalid size")
def test_invalid_board_size(self): board = get_board_from_api(8) self.assertEqual(board, "invalid size")
def test_board_size_4(self): board = get_board_from_api(4) self.assertEqual(len(board), 4) for column in range(4): self.assertEqual(len(board[column]), 4)
def test_invalid_board_size_parameterized(self, value): board = get_board_from_api(value) self.assertEqual(board, "Invalid size")
def set_game(self): self.get_size() self.play.set_board(get_board_from_api(self.size)) self.nice_board()