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)

Please complete the functions given in the chart below: CONSTANTS = {

add functions here:

slide_right (str, int, str) -> str The first parameter is the square being added to the game board. The second parameter is a row number and the third parameter is the string representation of a game board. Assume that the square, row number, and game board are valid. This function returns a string that is like the original game board, except that: - the square from the first parameter has been slid into the "beginning" (i.e., first column) of the given row number; - the square at the "end" (i.e., last column) has slid off the game board; - the remaining squares have slid to the right. slide_left (str, int, str) => str The first parameter is the square being added to the game board. The second parameter is a row and the third parameter is the string representation of a game board. Assume that the square, row number, and game board are valid. This function returns a string that is like the original game board, except that: - the square from the first parameter has been slid into the "end" (i.e., last column) of the given row number; - the square at the "beginning" (i.e., first column) has slid off the game board; - the remaining squares have slid to the left. slide_right (str, int, str) -> str The first parameter is the square being added to the game board. The second parameter is a row number and the third parameter is the string representation of a game board. Assume that the square, row number, and game board are valid. This function returns a string that is like the original game board, except that: - the square from the first parameter has been slid into the "beginning" (i.e., first column) of the given row number; - the square at the "end" (i.e., last column) has slid off the game board; - the remaining squares have slid to the right. slide_left (str, int, str) => str The first parameter is the square being added to the game board. The second parameter is a row and the third parameter is the string representation of a game board. Assume that the square, row number, and game board are valid. This function returns a string that is like the original game board, except that: - the square from the first parameter has been slid into the "end" (i.e., last column) of the given row number; - the square at the "beginning" (i.e., first column) has slid off the game board; - the remaining squares have slid to the left

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!