[Leet Code] Determine Color of a Chessboard Square

`Input: coordinates = "a1"Output: falseExplanation: From the chessboard above, the square with coordinates "a1" is black, so return false.`
`Input: coordinates = "h3"Output: trueExplanation: From the chessboard above, the square with coordinates "h3" is white, so return true.`
`Input: coordinates = "c7"Output: false`
`class Solution(object):    def squareIsWhite(self, coordinates):        """        :type coordinates: str        :rtype: bool        """        values = {"a":1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8}        if ((values[coordinates[0]] % 2 == 0 and int(coordinates[1]) % 2 == 0) or (int(values[coordinates[0]]) % 2 != 0 and int(coordinates[1]) % 2 != 0)):            return False        elif ((values[coordinates[0]] % 2 == 0 and int(coordinates[1]) % 2 != 0) or (values[coordinates[0]] % 2 != 0 and int(coordinates[1]) % 2 == 0)):            return True`

--

--

--

Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.

Matthew Boyd

Learning, and posting my findings!