from random import *

thelistone = list()
thelisttwo = list()

newlist = list()

newlistone = list()
newlisttwo = list()

newlistp1 = list()
newlistp2 = list()
newlistp3 = list()



thesum = 0
total = 0

maxN = 64
maxRun = 1

run = 0

v = 4
l = -v


def compound(a,b):
    if a == 1:
        if b == 1:
            return 1
        if b == -1:
            return 0
        if b == 0:
            return 1
    if a == -1:
        if b == 1:
            return 0
        if b == -1:
            return 1
        if b == 0:
            return -1
    if a == 0:
        if b == 1:
            return 1
        if b == -1:
            return -1
        if b == 0:
            return 0

def composite(oldlistone,oldlisttwo,newlist):
    for m in xrange(len(oldlistone)):
        if oldlistone[m] == -1 and oldlisttwo[m] == +1:
            newlist.append('E')
        if oldlistone[m] == +1 and oldlisttwo[m] == -1:
            newlist.append('E')
        if oldlistone[m] == 0 and oldlisttwo[m] == +1:
            newlist.append('T')
        if oldlistone[m] == 0 and oldlisttwo[m] == -1:
            newlist.append('F')
        if oldlistone[m] == -1 and oldlisttwo[m] == -1:
            newlist.append('F')
        if oldlistone[m] == -1 and oldlisttwo[m] == 0:
            newlist.append('F')
        if oldlistone[m] == +1 and oldlisttwo[m] == +1:
            newlist.append('T')
        if oldlistone[m] == +1 and oldlisttwo[m] == 0:
            newlist.append('T')
        if oldlistone[m] == 0 and oldlisttwo[m] == 0:
            newlist.append('0')

def product(oldlist,newlist,l):
    product = 0.0
    for m in xrange(l):
        product = compound(oldlist[m],product)
    newlist.append(productone)

while run < maxRun:
    run += 1

    thelist = list()
    l = -v
    while l < maxN:  
        l += 1
        
        productone = 0.0
        producttwo = 0.0
        
        U = random()*2-1
        if -1 < U < -.3333:
            V = -1
        if -.3333 < U < .3333:
            V = 0
        if .3333 < U < +1:
            V = +1
        thelistone.append(V)
        
        W = random()*2-1
        if -1 < W < -.3333:
            V = -1
        if -.3333 < W < .3333:
            V = 0
        if .3333 < W < +1:
            V = +1
        thelisttwo.append(V)
        
        if l > v:
            product(thelistone,newlistone,l)
            product(thelisttwo,newlisttwo,l)

    composite(thelistone,thelistone,newlistp1)
    composite(thelisttwo,thelisttwo,newlistp2)
    composite(thelistone,thelisttwo,newlistp3)

    print("list one")        
    print(newlistone)
    print("list two")
    print(newlisttwo)
    print("composite lists")
    print(newlistp1)
    print(newlistp2)
    print(newlistp3)











    
##    product(composite(thelistone,thelisttwo),newlistp,maxN-1)
##    print("new list p")
##    print(newlistp)
            
##    thesum = 0.0
##            
##    for m in xrange(maxN-1):
##        thesum += thelist[m]
##
##    total += thesum
##    
##    print("The Sum Result is:", thesum)
##    print("The Total is:", total/run)
