jweinst1
6/16/2015 - 8:35 AM

filtering orderd pairs.py

filtering orderd pairs.py

#method of filtering out ordered sets when only combinations are wanted.

def addition_pairs(sum):
	pairs = {(x,y) for x in range(sum) for y in range(sum) if x + y == sum}
	return pairs

def filtered_addition_pairs(sum):
	duets = [(x,y) for x in range(sum) for y in range(sum) if x + y == sum]
	for pair in duets:
		for samepair in duets: #doesnt work due to them being Non-Equal
			if pair[0] == samepair[1]:
				del samepair
	return duets

def additional_pairs(sum):
	duets = []
	for x in range(sum):
		for y in range(sum):
			if x + y == sum and (x,y) not in duets: #doesnt work due to bool value
				duets.append((x,y))
	return duets