python 列出具有multi和sum.py的压缩

Posted

tags:

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



def compress_list_multi(list): #multiplies the first half of a list by the indexes in the second half.
	midpoint = (len(list) / 2)
	one, two = list[0:midpoint], list[midpoint:len(list)]
	return [one[i]*two[i] for i in range(len(one))]
def compress_list_sum(list):
	midpoint = (len(list) / 2)
	one, two = list[0:midpoint], list[midpoint:len(list)]
	return [one[i]+two[i] for i in range(len(one))]
def compress_all_multi(list): #reduces a list to a single entry by multiplying all items.
	while len(list) > 1:
		midpoint = (len(list) / 2)
		one, two = list[0:midpoint], list[midpoint:len(list)]
		list = [one[i]*two[i] for i in range(len(one))]
	return list
def compress_all_sum(list): #reduces a list to a single enty by adding all items. 
	while len(list) > 1:
		midpoint = (len(list) / 2)
		one, two = list[0:midpoint], list[midpoint:len(list)]
		list = [one[i]+two[i] for i in range(len(one))]
	return list
	
	

以上是关于python 列出具有multi和sum.py的压缩的主要内容,如果未能解决你的问题,请参考以下文章

python 18.4sum.py

python 15. 3Sum.py

Python Web 性能和压力测试 multi-mechanize

在Windows上的python 2.7中列出具有Unicode名称的文件

Boost::multi_index_container 具有不同的键和元素类型

很好用的压测工具 - Apache Bench工具