|
发表于 2020-4-6 12:14:33
|
显示全部楼层
本帖最后由 chen971130 于 2020-4-6 12:21 编辑
- def func(start, end, a, b, c):
- start,end = list(start),list(end)
- for i in range(len(start)-1):
- if start[i] == a and start[i+1] == b:
- if end[i] == a and end[i+1] == b:
- continue
- elif end[i] == b and end[i+1] == b:
- if start[i+c] == b and end[i+c] == a:
- continue
- else:
- return False
- else:
- return False
- else:
- return True
- def a369(start,end):
- if len(start) != len(end):
- print('False')
- else:
- start1,end1 = start.replace('X', ''),end.replace('X', '')
- if start1 != end1:
- print('False')
- else:
- if func(start, end, 'X', 'R', -1) and func(start, end, 'L', 'X', 2):
- print('True')
- else:
- print('False')
- a369("RXXLRXRXL", "XRLXXRRLX") # True
复制代码 |
评分
-
查看全部评分
|