标签:
def eight_queen(): def if_inline(point1, point2): if(point1[0] == point2[0] or\ abs(point1[0] - point2[0]) == abs(point1[1] - point2[1])): return True return False def judge_point(point, point_list): for item in point_list: if(if_inline(point, item)): return False else: return True def sub_func(height, width, cloumn, point_list): for i in range(height): point = (i, cloumn) if(judge_point(point, point_list)): point_list_new = copy.deepcopy(point_list) point_list_new.append(point) if(cloumn < height-1): sub_func(height, width, cloumn+1, point_list_new) else: print point_list_new return
标签:
原文地址:http://www.cnblogs.com/wingor/p/4657892.html