Question
Please complete the functions given in the chart below: CONSTANTS = { 'N_COLUMNS': 5, 'N_ROWS': 4, 'BLACK_SQUARE': '#', 'RED_SQUARE': 'R', 'YELLOW_SQUARE': 'Y', 'ACROSS': 'across', 'DOWN':
Please complete the functions given in the chart below:
CONSTANTS = {
'N_COLUMNS': 5,
'N_ROWS': 4,
'BLACK_SQUARE': '#',
'RED_SQUARE': 'R',
'YELLOW_SQUARE': 'Y',
'ACROSS': 'across',
'DOWN': 'down',
'DOWN_RIGHT': 'dright',
'DOWN_LEFT': 'dleft'
}
# The next several lines contain constants for you to use in your code. # You must use these constants instead of the values they refer to. # For example, use BLACK_SQUARE instead of '#'. # You may not need to use all of the constants provided. # Do not change the values these constants refer to.
N_COLUMNS = 5 # Number of columns in the game board N_ROWS = 4 # Number of rows in the game board
BLACK_SQUARE = '#' # The character that represents a black square RED_SQUARE = 'R' # The character that represents a red square YELLOW_SQUARE = 'Y' # The character that represents a blue square
ACROSS = 'across' # The horizontal direction DOWN = 'down' # The vertical direction DOWN_RIGHT = 'dright' # The diagonal direction: downward and rightward DOWN_LEFT = 'dleft' # The diagonal direction: downward and leftward
# This function is completed for you as an example and you must not change it. def create_empty_board() -> str: """Return a string representation of a game board of all empty symbols with N_ROWS rows and N_COLUMNS columns. """ return BLACK_SQUARE * N_ROWS * N_COLUMNS
def is_board_full(game_board: str) -> bool: """Return True if and only if the game_board is full.
A game_board is full when it does not contain any BLACK_SQUARE characters.
>>> is_board_full('R########YR####Y####') False >>> is_board_full('RYYRYYRYYRYYRYYRYYRY') True """
return BLACK_SQUARE not in game_board
def between(value: str, min_value: int, max_value: int) -> bool: """Return True if and only if value is between min_value and max_value, inclusive.
Preconditions: - value can be converted to an integer without error - min_value
>>> between('2', 0, 2) True >>> between('0', 2, 3) False """ return int (value) in range (min_value,min_value+1)
add functions here:
get_row (int, str) -> str The first parameter is a row number and the second parameter is the string representation of a game board. Assume that the row number and game board are valid. The game board size is given by the constants N_ROWS and N_COLUMNS This function returns only the characters in the game board found at the given row in the same left-to-right order as they appear in the row. get_column (int, str) -> The first parameter is a column number and the second parameter is the string representation of a game board. Assume that the column number and game board are valid. The game board size is given by the constants N_ROWS and N_COLUMNS This function returns only the characters in the game board found at the given column in the same top-to-bottom order as they appear in the column. trStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started