Bird
0
0
LLDsystem_design~10 mins

Win condition checking in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if a player has won by filling the blank.

LLD
if board[row][col] == [1]:
    return True
Drag options to blanks, or click blank then click option'
Aplayer_symbol
Bempty_cell
Copponent_symbol
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using empty_cell instead of player_symbol
Checking for opponent_symbol instead of player_symbol
2fill in blank
medium

Complete the code to count consecutive symbols in a row.

LLD
count = 0
for c in range(len(board[0])):
    if board[row][c] == [1]:
        count += 1
Drag options to blanks, or click blank then click option'
Aempty_cell
Bplayer_symbol
Copponent_symbol
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Counting empty cells instead of player symbols
Counting opponent symbols by mistake
3fill in blank
hard

Fix the error in the diagonal win check by filling the blank.

LLD
for i in range(size):
    if board[i][i] != [1]:
        return False
return True
Drag options to blanks, or click blank then click option'
Aempty_cell
Bopponent_symbol
CNone
Dplayer_symbol
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for empty cells instead of player symbols
Checking for opponent symbols
4fill in blank
hard

Fill both blanks to check vertical win condition correctly.

LLD
for r in range(size):
    if board[r][col] != [1]:
        return False
return [2]
Drag options to blanks, or click blank then click option'
Aplayer_symbol
BTrue
CFalse
Dempty_cell
Attempts:
3 left
💡 Hint
Common Mistakes
Returning False instead of True after the loop
Checking for empty cells instead of player symbols
5fill in blank
hard

Fill all three blanks to complete the function that checks horizontal, vertical, and diagonal wins.

LLD
def check_win(board, player):
    size = len(board)
    for i in range(size):
        if all(board[i][j] == [1] for j in range(size)):
            return [2]
        if all(board[j][i] == [1] for j in range(size)):
            return [2]
    if all(board[i][i] == [1] for i in range(size)):
        return [2]
    if all(board[i][size - 1 - i] == [1] for i in range(size)):
        return [2]
    return [3]
Drag options to blanks, or click blank then click option'
Aplayer
BTrue
CFalse
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Returning None instead of False when no win
Checking wrong symbols in conditions