0
0
LLDsystem_design~10 mins

Special moves (castling, en passant) 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 castling is allowed by verifying the king's and rook's {{BLANK_1}} status.

LLD
if not king.[1] and not rook.[1]:
    allow_castling = True
Drag options to blanks, or click blank then click option'
Ais_attacked
Bcan_move
Cis_checked
Dhas_moved
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'has_moved' with 'can_move' or 'is_checked'.
2fill in blank
medium

Complete the code to detect if en passant capture is possible by checking the opponent pawn's {{BLANK_1}} move.

LLD
if opponent_pawn.last_move == [1]:
    allow_en_passant = True
Drag options to blanks, or click blank then click option'
Asingle_step
Bdouble_step
Ccapture_move
Dcastle_move
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'single_step' or other move types instead of 'double_step'.
3fill in blank
hard

Fix the error in the castling validation by correctly checking if the squares between king and rook are {{BLANK_1}}.

LLD
for square in squares_between:
    if square.[1]:
        return False
Drag options to blanks, or click blank then click option'
Ais_occupied
Bis_empty
Cis_attacked
Dis_safe
Attempts:
3 left
💡 Hint
Common Mistakes
Checking if squares are empty instead of occupied.
4fill in blank
hard

Fill both blanks to correctly update the board after an en passant move.

LLD
board.move_piece(pawn, [1])
board.remove_piece([2])
Drag options to blanks, or click blank then click option'
Atarget_square
Bcaptured_pawn_square
Cpawn.position
Den_passant_capture_square
Attempts:
3 left
💡 Hint
Common Mistakes
Removing the wrong piece or moving the pawn incorrectly.
5fill in blank
hard

Fill all three blanks to implement castling: move the king, move the rook, and update their {{BLANK_1}}, {{BLANK_2}}, and {{BLANK_3}} status.

LLD
board.move_piece(king, [1])
board.move_piece(rook, [2])
king.[3] = True
rook.[3] = True
Drag options to blanks, or click blank then click option'
Aking_target_square
Brook_target_square
Chas_moved
Dcan_castle
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong target squares or wrong status properties.