当前位置:网站首页>[daily 3 questions (1)] judge the color of a grid on the chess board
[daily 3 questions (1)] judge the color of a grid on the chess board
2022-06-29 11:13:00 【Programmed ape without hair loss 2】
subject :
Give you a coordinate coordinates , It's a string , Represents the coordinates of a grid in a chess board . The following is a schematic diagram of the chess board .

If the color of the given grid is white , Please return true, If it's black , Please return false .
The given coordinates must represent an existing grid on the chess board . The first character in the coordinates is the letter , The second character is the number .
Example 1:
Input :coordinates = “a1”
Output :false
explain : As shown on the chessboard above ,“a1” The coordinates of the grid are black , So back false .
Example 2:
Input :coordinates = “h3”
Output :true
explain : As shown on the chessboard above ,“h3” The grid of coordinates is white , So back true .
Example 3:
Input :coordinates = “c7”
Output :false
Tips :
coordinates.length == 2
‘a’ <= coordinates[0] <= ‘h’
‘1’ <= coordinates[1] <= ‘8’
java Code :
class Solution {
public boolean squareIsWhite(String coordinates) {
return (coordinates.charAt(0) + coordinates.charAt(1)) %2>0;
}
}
边栏推荐
- LVGL库入门教程 - 动画
- 当技术人成长为 CEO,应该修改哪些“Bug”?
- Google Earth engine (GEE) - Gedi L2a vector canopy top height (version 2) global ecosystem data set
- Specific method and example program of Siemens s7-200smart control stepping motor
- (JS) status mode
- Using EasyX configuration in clion
- “AI x 科学计算”进行时,华为昇思 MindSpore 赛题火热开启,等你来!
- 多线程高并发服务器:3个问题
- TTL serial port learning infrared remote control module can be extended to network control
- ModbusTCP协议网络学习型单路红外模块(双层板)
猜你喜欢

Cs231n-2022 module1: overview of key points of neural network (2)

如何识别出轮廓准确的长和宽

世界上第一个“半机械人”去世,改造自己只为“逆天改命”

When the "Ai x scientific computing" is in progress, Huawei's mindspore competition question is hot, waiting for you!

什么?漫画居然能免费看全本了,这还不学起来一起做省钱小能手

ModbusTCP协议WIFI无线学习型单路红外模块(圆壳版)

任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过

Data analysis method and Thinking: funnel analysis

(JS)筛选出对象中value大于2的key

多线程高并发服务器:3个问题
随机推荐
(JS)筛选出对象中value大于2的key
STM32F1與STM32CubeIDE編程實例-超聲波測距傳感器驅動
嵌入式学习书籍推荐[通俗易懂]
Pytorch learning notes (6) -- source code analysis of dataloader
9 easy to use JSON processing tools, greatly improving efficiency!
NUC980开源项目16-从SPI FLASH(W25Q128)启动
Shell 中你不得不熟知的变量运用
【每日3题(2)】生成交替二进制字符串的最少操作数
USB to RS485 serial port circuit design "suggestions collection"
Bs-gx-018 student examination system based on SSM
Limit introduction summary
crypto 1~5
The last 48 hours! The cloud XR theme competition invites you to bloom together. See you at the competition!
企业竞争分析的几种方法:SWOT、波特五力、PEST「建议收藏」
Pipeline aggregations管道聚合- parent-2
misc3~7
ModbusTCP协议WIFI无线学习型单路红外模块(小壳版)
Mysql获取表信息
什么?漫画居然能免费看全本了,这还不学起来一起做省钱小能手
Xiaomi mobile phone - Unlock BL + open root permission