参加周赛,时间有限,没啥想法,写了很奇怪的答案。
class Solution:
def squareIsWhite(self, coordinates: str) -> bool:
list1="01010101"
list2="10101010"
if coordinates[0] in "aceg":
flag=list1[int(coordinates[1])-1]
else:
flag = list2[int(coordinates[1]) - 1]
if flag == "0":
return False
else:
return True
怎么这都不是一个正经的答案,但是能过。
后来仔细想想,只要把a1拆开,判断a+1是不是偶数就能知道答案了。一行解决
class Solution:
def squareIsWhite(self, coordinates: str) -> bool:
return True if ((ord(coordinates[0]))+int(coordinates[1])) % 2 else False
Hello there,
what has happened to follow.steems.top? The page is down, and I really liked it and loved to use it!! :) Please help :) Would happily send you some Steem as a thank you as well if you made it work once again!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit