python 缩短搜索Algorithm.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 缩短搜索Algorithm.py相关的知识,希望对你有一定的参考价值。

def Shortening_search(target):
	assert 0<target<1000 #must be between 1 and 999.
	list, count = range(1000), 0
	while len(list) > 1:
		if list[0] == target:
			return count
		elif list[-1] == target:
			return count
		else:
			list.pop()
			list.remove(list[0])
			count += 1
	return count

以上是关于python 缩短搜索Algorithm.py的主要内容,如果未能解决你的问题,请参考以下文章