二分法10个硬币找一个假币
import randomdef FindMoney(aList):
if len(aList) == 2:
if aList[0] > aList[1]:
print aList[1]
else:
print aList[0]
else:
if sum(aList[len(aList)/2:]) > sum(aList[:len(aList)/2]):
FindMoney(aList[:len(aList)/2])
else:
FindMoney(aList[len(aList)/2:])
a = [10] *9 + [9]
a.sort(lambda a,b: random.randint(-1, 1))
print a
FindMoney(a)
怎么修改