当前位置:网站首页>[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;
}
}
边栏推荐
- (JS)职责链模式
- 在Clion中使用EasyX配置
- (JS)isNaN()方法判断undefined为true的原因
- LVGL库入门教程 - 动画
- Stm32f1 and stm32subeide programming example - ultrasonic distance sensor drive
- Online sql to htmltable tool
- [FreeRTOS] 08 mutex semaphores and priority inversion
- [digital signal modulation] realize signal modulation and demodulation based on am+fm+dsb+ssb, including Matlab source code
- Exemples de programmation stm32f1 et stm32cubeide - entraînement du capteur de portée ultrasonique
- 第12周实验---基于FPGA的VGA协议实现
猜你喜欢

励志!专科“逆袭”读浙大硕士,3篇SCI,最终成清华博士!

最后的 48 小时!云 XR 专题赛邀你一起绽放精彩,我们赛场见!

当技术人成长为 CEO,应该修改哪些“Bug”?

Google Earth engine (GEE) - Gedi L2a vector canopy top height (version 2) global ecosystem data set

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

Multi thread communication between client and server (primary version)

多线程高并发服务器:3个问题

The encryption market has exploded one after another. Can Celsius avoid bankruptcy?

历史上的今天:马斯克出生;微软推出 Office 365;蔡氏电路的发明者出生

Modbustcp protocol WiFi wireless learning single channel infrared module (small shell version)
随机推荐
MATLAB basic Max to find the maximum value of one-dimensional or two-dimensional array +sleep (pause)
Ningde era Kirin battery has greater ambition
Nuc980 open source project 16- start from SPI flash (w25q128)
Modbustcp protocol WiFi wireless learning single channel infrared module (small shell version)
math_数学表达式&等式方程的变形&组合操作技巧/手段积累
Spark - Task 与 Partition 一一对应与参数详解
嵌入式驱动开发之uboot---uboot 中的常见命令参数参数
Nuc980 started successfully
Easydss is deployed on Disk C, and the video playback cannot be played normally. How to solve this problem?
Reids设计与实现
掌握一些shell 通配符巧妙的运用,会让我们写脚本事半功倍
NUC980开源项目16-从SPI FLASH(W25Q128)启动
LVGL库入门教程 - 动画
【每日3题(2)】生成交替二进制字符串的最少操作数
ModbusTCP协议WIFI无线学习型单路红外模块(圆壳版)
什么?漫画居然能免费看全本了,这还不学起来一起做省钱小能手
Exemples de programmation stm32f1 et stm32cubeide - entraînement du capteur de portée ultrasonique
Mastering the clever use of some shell wildcards will make us write with half the effort
《Datawhale推荐系统教程》来了!
Week 12 experiment -- implementation of VGA protocol based on FPGA