Same-Color Chessboard Positions
Problem statement
Given two positions first and second on a standard 8 x 8 chessboard, return true if they have the same color and false otherwise.
A position uses lowercase algebraic notation: a file from a to h followed by a rank from 1 to 8. Moving one square horizontally or vertically changes the color.
Function
sameColor(first: String, second: String) → booleanExamples
Example 1
first = "a1"second = "c3"return = trueMoving from a1 to c3 takes two horizontal and two vertical steps. The four color changes return to the starting color, so the answer is true.
Example 2
first = "a1"second = "a2"return = falsea1 and a2 are one vertical step apart. Their colors differ, so the answer is false.
Constraints
first.length = second.length = 2.- Each position consists of one lowercase file from
athroughh, followed by one rank from1through8. - Both positions are valid squares on a standard
8 x 8chessboard. They may be equal.