-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.py
37 lines (31 loc) · 907 Bytes
/
circle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# encoding: utf-8
'''
@author: Lingcheng Dai
@contact: 2013210288@bupt.edu.cn
@file: circle.py
@time: 2018/7/31 17:27
'''
moves = "UD"
class Solution:
def judgeCircle(self, moves):
"""
:type moves: str
:rtype: bool
"""
# origin_x = 0
# origin_y = 0
# for move in moves:
# if move == 'U':
# origin_y += 1
# elif move == 'D':
# origin_y -= 1
# elif move == 'L':
# origin_x -= 1
# elif move == 'R':
# origin_x += 1
# return ([origin_x, origin_y] == [0, 0])
# return ((moves.count('U') == moves.count('D')) & (moves.count('L') == moves.count('R')))
# return not sum(map(1j.__pow__, map('RUL'.find, moves)))
return not sum(1j ** 'RUL'.find(m) for m in moves)
s = Solution
print(s.judgeCircle(s, moves))