|
发表于 2003-7-15 12:39:38
|
显示全部楼层
python程序,就是效率比较低
#!/usr/bin/python
f0 = lambda min,max:map(lambda (x,y) : (x,y,x+y,x*y), \
[(x,y) for x in range(min,max) for y in range(min,max) if x <= y])
f1 = lambda elm,lst:len(filter(lambda e1,elm=elm:e1[2] == elm[2], lst)) > 1 and len(filter(lambda e1,elm=elm:e1[2] == elm[2] and f2(e1, lst), lst)) == 0
f2 = lambda elm,lst: len(filter(lambda e1,elm=elm:e1[3] == elm[3], lst)) == 1
f3 = lambda elm,lst: len(filter(lambda e1,elm=elm:e1[2] == elm[2], lst)) == 1
set0 = f0(2, 100)
set1 = filter(lambda elm,lst=set0:f1(elm,lst), set0)
set2 = filter(lambda elm,lst=set1:f2(elm,lst), set1)
set3 = filter(lambda elm,lst=set2:f3(elm,lst), set2)
print set3 |
|