start = [0, 0]
end = [0, 0]
axis = [[1, 2], [2, 1], [2, -1], [1, -1], [-1, -2], [-2, -1], [-2, 1], [-1, 2]]
step = 5
M = 0
startx = []
starty = []
def horse_run(k):
global M
for each in axis:
startx.append(each[0])
starty.append(each[1])
if k == step and sum(startx) == end[0] and sum(starty) == end[1]:
M += 1
print("%d: "%M, [(k, v) for k, v in zip(startx, starty)])
else:
if k < step and 0<= sum(startx) <=8 and 0<= sum(starty) <= 9:
horse_run(k+1)
startx.pop()
starty.pop()
horse_run(1)
文章转载自
点击打开链接
京东马走日笔试题
猜你喜欢
转载自blog.csdn.net/z2539329562/article/details/80745337
今日推荐
周排行