Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribed

add functions here:

The parameter refers to a string that describes one of the four directions: down, across, down- right, or down-left. Assume that the str value is one of: DOWN, ACROSS DOWN_RIGHT, or DWON_LEFT. calculate_increment The game board size is given by (str) -> int the constants N_ROWS and N_COLUMNS This function returns the difference between the string indices of two adjacent squares on a line that goes in the direction specified by the first parameter. 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 get_row (int, str) -> str 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. The parameter refers to a string that describes one of the four directions: down, across, down- right, or down-left. Assume that the str value is one of: DOWN, ACROSS DOWN_RIGHT, or DWON_LEFT. calculate_increment The game board size is given by (str) -> int the constants N_ROWS and N_COLUMNS This function returns the difference between the string indices of two adjacent squares on a line that goes in the direction specified by the first parameter. 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 get_row (int, str) -> str 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions