1812. Determine Color of a Chessboard Square Easy
1/**
2 * [1812] Determine Color of a Chessboard Square
3 *
4 * You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.
5 * <img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/screenshot-2021-02-20-at-22159-pm.png" style="width: 400px; height: 396px;" />
6 * Return true if the square is white, and false if the square is black.
7 * The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.
8 *
9 * Example 1:
10 *
11 * Input: coordinates = "a1"
12 * Output: false
13 * Explanation: From the chessboard above, the square with coordinates "a1" is black, so return false.
14 *
15 * Example 2:
16 *
17 * Input: coordinates = "h3"
18 * Output: true
19 * Explanation: From the chessboard above, the square with coordinates "h3" is white, so return true.
20 *
21 * Example 3:
22 *
23 * Input: coordinates = "c7"
24 * Output: false
25 *
26 *
27 * Constraints:
28 *
29 * coordinates.length == 2
30 * 'a' <= coordinates[0] <= 'h'
31 * '1' <= coordinates[1] <= '8'
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/determine-color-of-a-chessboard-square/
37// discuss: https://leetcode.com/problems/determine-color-of-a-chessboard-square/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn square_is_white(coordinates: String) -> bool {
43 false
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_1812() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.