classSolution{public:boolcheckTwoChessboards(stringcoordinate1,stringcoordinate2){returnsquareIsWhite(coordinate1)==squareIsWhite(coordinate2);}private:// Same as 1812. Determine Color of a Chessboard SquareboolsquareIsWhite(conststring&coordinates){constcharletter=coordinates[0];constchardigit=coordinates[1];returnletter%2!=digit%2;}};
1 2 3 4 5 6 7 8 9101112
classSolution{publicbooleancheckTwoChessboards(Stringcoordinate1,Stringcoordinate2){returnsquareIsWhite(coordinate1)==squareIsWhite(coordinate2);}// Same as 1812. Determine Color of a Chessboard SquareprivatebooleansquareIsWhite(finalStringcoordinates){finalcharletter=coordinates.charAt(0);finalchardigit=coordinates.charAt(1);returnletter%2!=digit%2;}}
12345678
classSolution:defcheckTwoChessboards(self,coordinate1:str,coordinate2:str)->bool:# Same as 1812. Determine Color of a Chessboard SquaredefsquareIsWhite(coordinate:str)->bool:letter,digit=coordinatereturnord(letter)%2!=int(digit)%2returnsquareIsWhite(coordinate1)==squareIsWhite(coordinate2)