fix: 增加日记记录
This commit is contained in:
24
language/Python区块链/tempCodeRunnerFile.python
Normal file
24
language/Python区块链/tempCodeRunnerFile.python
Normal file
@@ -0,0 +1,24 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
def is_valid_walk(walk):
|
||||
if len(walk) != 10:
|
||||
return False
|
||||
|
||||
hasWalk = list()
|
||||
|
||||
for m in walk:
|
||||
if (m == 'n' and hasWalk.index('s')>=0):
|
||||
hasWalk.remove(hasWalk.index('s'))
|
||||
elif (m == 's' and hasWalk.index('n')>=0):
|
||||
hasWalk.remove(hasWalk.index('n'))
|
||||
elif (m == 'e' and hasWalk.index('w')>=0):
|
||||
hasWalk.remove(hasWalk.index('w'))
|
||||
elif (m == 'w' and hasWalk.index('e')>=0):
|
||||
hasWalk.remove(hasWalk.index('e'))
|
||||
else:
|
||||
hasWalk.append(m)
|
||||
|
||||
return len(hasWalk) == 0
|
||||
|
||||
print(is_valid_walk(['n','s','n','s','n','s','n','s','n','s']))
|
||||
Reference in New Issue
Block a user