摘要: def eight_queen(): def if_inline(point1, point2): if(point1[0] == point2[0] or\ abs(point1[0] - point2[0]) == abs(point1[1] - poi... 阅读全文
posted @ 2015-07-18 23:21 wingor 阅读(198) 评论(0) 推荐(0) 编辑
摘要: def barska(n): res = [1] for i in range(n): print (' '*(n-i)), res.insert(0, 0) for j in range(len(res)-2): res... 阅读全文
posted @ 2015-07-01 23:20 wingor 阅读(611) 评论(0) 推荐(0) 编辑
摘要: 了解过python字典的人都知道一句话,字典的键必须不可变,所以可以用数,字符串或元组充当,列表就不行。 那么,为什么可变类型不能当作键呢? 自定义类型可以做键吗? 首先,我们看看list做键值的情况lsta = [1,2,3]dicta = {lsta:1}>>>TypeError: u... 阅读全文
posted @ 2015-05-12 17:03 wingor 阅读(2032) 评论(0) 推荐(0) 编辑
摘要: 题目:把只包含质因子2、3和5的数称作丑数(Ugly Number),例如:2,3,4,5,6,8,9,10,12,15,等,要求写一个算法获取第1500个丑数。一,顺序查找,主要用来检验其他方法是否正确数字递增,挨个判断是否是丑数def if_ugly(num): while(num%2 =... 阅读全文
posted @ 2015-05-11 16:03 wingor 阅读(501) 评论(0) 推荐(0) 编辑