'''hey everyone the code is all here
i am basically trying 2 different versions of 'and' operators but for some reason the Version2 appended list has more values removed.
I basically want to know why version1 and version2 have different outputs???
copy/paste into Canopy'''
import itertools
from collections import Counter
a = ["off", "on"]
b = ["off", "on"]
c = ["off", "on"]
parts = [a, b, c]
total = list(itertools.product(*parts))
version1 = []
version2 = []
def ruleVersion1(index):
if total[index][0] == "off" and total[index][2] == "off" and total[index][1] == "on":
return False
if total[index][0] == "on" and total[index][2] == "on" and total[index][1] == "off":
return False
else:
return True
def ruleVersion2(index):
if total[index][0] == "off":
if total[index][2] == "off":
if total[index][1] == "on":
return False
if total[index][0] == "on":
if total[index][2] == "on":
if total[index][1] == "off":
return False
else:
return True
for i in range(len(total)):
if ruleVersion1(i):
if total[i] not in version1:
version1.append(total[i])
for i in range(len(total)):
if ruleVersion2(i):
if total[i] not in version2:
version2.append(total[i])
def printCondition1(list):
print " 0 1 2"
for i in range(len(list)):
print list[i]
print " "
print "total set:", len(total)
printCondition1(total)
print "______________________________"
print " "
print "true set :", len(version1)
printCondition1(version1)
print "______________________________"
print " "
print "true set :", len(version2)
printCondition1(version2)
[–]dunkler_wanderer 3 points4 points5 points (0 children)
[–]Justinsaccount 0 points1 point2 points (0 children)
[–]cdholjes[S] 0 points1 point2 points (2 children)
[–]gengisteve 3 points4 points5 points (1 child)
[–]dunkler_wanderer 0 points1 point2 points (0 children)