Problem:
Given the positions of a white bishop and a black pawn on the standard chess board, determine whether the bishop can capture the pawn in one move.
The bishop has no restrictions in distance for each move, but is limited to diagonal movement. Check out the example below to see how it can move:
Example
-
For bishop = "a1" and pawn = "c3", the output should be
bishopAndPawn(bishop, pawn) = true. -
For bishop = "h1" and pawn = "h3", the output should be
bishopAndPawn(bishop, pawn) = false.-Summary-
1. ord 와 abs 함수를 이용하여 bishop과 pawn 의 포지션의 값으로 true 또는 false값 리턴
처음에 많이 해매다가 discussion에서 힌트를 얻고 문제를 풀었다. 아직도 체스 위치와 Ascii code를 써서 문제를 푸는 방식은 익숙하지가 않다.
모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]
'CodeSignal > Arcade' 카테고리의 다른 글
CodeSignal [44/60] findEmailDomain (0) | 2020.05.26 |
---|---|
CodeSignal [43/60] isBeautifulString (0) | 2020.05.26 |
CodeSignal [41/60] digitDegree (0) | 2020.05.26 |
CodeSignal [40/60] longestDigitsPrefix (0) | 2020.05.26 |
CodeSignal [39/60] knapsackLight (0) | 2020.05.26 |
댓글