An atrium floor is covered by an 8x8 mosaic of square tiles. Columns are labeled with a lowercase letter from 'a' (leftmost) to 'h' (rightmost), and rows are labeled with a digit from '1' (nearest edge) to '8' (farthest edge), so every tile has a unique two-character label such as "a1" or "h8". The mosaic alternates shade in a strict checkerboard pattern: any two tiles that share an edge always have different shades. Given the labels of two tiles, determine whether they have the same shade.
Two lines, each containing one tile label: a lowercase letter from 'a' to 'h' followed immediately by a digit from '1' to '8' (no space between them).
coord1coord2Print true if the two tiles have the same shade, or false otherwise.
coord1 and coord2 is exactly 2 characters: a letter in [a-h] followed by a digit in [1-8].Example 1
Input
a1 c3
Expected
true
Explanation
Tile a1 sits at zero-indexed column 0, row 0 (sum 0, even). Tile c3 sits at column 2, row 2 (sum 4, even). Both sums are even, so the tiles share the same shade — output true.
Example 2
Input
a1 h3
Expected
false
Explanation
Tile a1 is at column 0, row 0 (sum 0, even). Tile h3 is at column 7, row 2 (sum 9, odd). The sums have different parity, so the tiles have different shades — output false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →