Bird
Raised Fist0

Which of the following code snippets correctly represents the en passant capture condition check?

easy🧠 Conceptual Q3 of Q15
LLD - Design — Chess Game
Which of the following code snippets correctly represents the en passant capture condition check?
Aif pawn.position == opponent_pawn.position - (0, 2) and opponent_pawn.just_moved_one_step:
Bif pawn.position == opponent_pawn.position + (1, 0) and opponent_pawn.just_moved_two_steps:
Cif pawn.position == opponent_pawn.position + (0, 1) and opponent_pawn.just_moved_two_steps:
Dif pawn.position == opponent_pawn.position + (0, 2) and opponent_pawn.just_moved_two_steps:
Step-by-Step Solution
Solution:
  1. Step 1: Understand en passant capture logic

    En passant occurs when a pawn moves two steps forward and an opponent pawn is adjacent.
  2. Step 2: Check correct position and move conditions

    The capturing pawn must be next to the opponent pawn's position plus one step forward.
  3. Final Answer:

    if pawn.position == opponent_pawn.position + (0, 1) and opponent_pawn.just_moved_two_steps: -> Option C
  4. Quick Check:

    En passant condition code = B [OK]
Quick Trick: En passant checks adjacent pawn just moved two steps [OK]
Common Mistakes:
MISTAKES
  • Using wrong position offsets
  • Checking for one step move instead of two
  • Mixing horizontal and vertical directions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes