|
发表于 2017-2-9 20:20:41
|
显示全部楼层
本帖最后由 Jonin616 于 2017-2-9 20:24 编辑
- move = [(1,2),(2,1),(2,-1),(1,-2),(-1,-2),(-2,-1),(-2,1),(-1,2)]
- hlocate = [0,0]
- step = []
- step.append(hlocate.copy())
- dep = 1
- hlocate_next = [0,0]
- def find(hlocate,dep):
- #print(dep,step)
- if dep == 65:
- return 1
- for each in move:
- if (0 <= hlocate[0] + each[0] <= 7 and 0 <= hlocate[1] + each[1] <=7 and [hlocate[0] + each[0],hlocate[1] + each[1]] not in step):
- hlocate_next[0] = hlocate[0] + each[0]
- hlocate_next[1] = hlocate[1] + each[1]
- step.append(hlocate_next.copy())
-
- if find(hlocate_next,dep + 1) == 1:
- return 1
- else:
- step.remove(step[len(step) - 1])
- hlocate = step[len(step) - 1].copy()
- return 0
- def fuckit():
- if find(hlocate,dep + 1) == 1:
- print(step)
- print('成功')
- fuckit()
复制代码 |
|