Skip to content

Commit ad46c2c

Browse files
authored
Create minimum-moves-to-capture-the-queen.py
1 parent b40f46b commit ad46c2c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Time: O(1)
2+
# Space: O(1)
3+
4+
# math
5+
class Solution(object):
6+
def minMovesToCaptureTheQueen(self, a, b, c, d, e, f):
7+
"""
8+
:type a: int
9+
:type b: int
10+
:type c: int
11+
:type d: int
12+
:type e: int
13+
:type f: int
14+
:rtype: int
15+
"""
16+
if a == e and not (a == c and (b-d)*(f-d) < 0):
17+
return 1
18+
if b == f and not (b == d and (a-c)*(e-c) < 0):
19+
return 1
20+
if c+d == e+f and not (c+d == a+b and (c-a)*(e-a) < 0):
21+
return 1
22+
if c-d == e-f and not (c-d == a-b and (d-b)*(f-b) < 0):
23+
return 1
24+
return 2

0 commit comments

Comments
 (0)