1. 问题描述
把一个数组分成两堆,列举所有可能性。也就是排列组合
2. 解决方案
class node:
def __init__(self, value, ind, nex = None):
self.value = value
self.ind = ind
self.nex = nex
def set_next(self,nex):
self.nex = nex
def get_next(self):
return self.nex
def is_end(self):
if self.nex is None:
return True
return False
class link:
def __init__(self):
self.data = []
self.last = None
def add(self,value):
if self.last is not None:
self.last.set_next(node(value,len(self.data)))
self.last = self.last.get_next()
else:
self.last = node(value,len(self.data))
self.data.append(self.last)
def get_array(lis):
result = []
for i in lis:
result.append(i.value)
return result
def cop(obj,lis):
ind = []
result = []
for i in l