Ctrl K

Matching Square Shades

Easy
An 8 × 8 chessboard is coloured the usual way: square a1 is dark, and horizontally or vertically neighbouring squares alternate in colour. A square is written as a column letter a to h followed by a row digit 1 to 8, e.g. "e4". Given two squares first and second, return True if they share a colour and False otherwise.
Example 1
first="b1", second="e4" → True

Both squares are light: they lie on the same diagonal.

Example 2
first="d4", second="d5" → False

Vertically adjacent squares always differ in colour.

Example 3
first="h8", second="a1" → True
Constraints
  • len(first) == len(second) == 2
  • The first character is a letter from a to h
  • The second character is a digit from 1 to 8
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasySum of Binary Strings EasySpreadsheet Column Label EasySpreadsheet Column Index EasyCounting Off by Threes and Fives Easy
loading Python…
Input
first="b1", second="e4"
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 156 tests on the server, hidden ones included.