← Back to challenges

Capture the Rook

PythonHardarraysgamesvalidationconditions

Instructions

Write a function that returns True if two rooks can attack each other, and False otherwise.

Examples

can_capture(["A8", "E8"]) ➞ True

can_capture(["A1", "B2"]) ➞ False

can_capture(["H4", "H3"]) ➞ True

can_capture(["F5", "C8"]) ➞ False

Notes

  • Assume no blocking pieces.
  • Two rooks can attack each other if they share the same row (letter) or column (number).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Remove None from a List