Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from multiprocessing import Process,Lock,Pool
- from multiprocessing.sharedctypes import Value
- final = []
- def check_values(i,listofnumbers,listlength,total):
- for i1 in range(0,listlength + 1 - i):
- numbers = []
- countofnumbers=[]
- currentlist = listofnumbers[i1:listlength-abs(i-listlength+i1)]
- #print "I:",i,",TR nIZ ",tr_niz
- for k in currentlist:
- if k not in numbers:
- numbers.append(k)
- countofnumbers.append(currentlist.count(k) if currentlist.count(k)%2==0 else 0)
- if 0 not in countofnumbers:
- if sum(countofnumbers)%2==0:
- print "Hello"
- total.value+=1
- try:
- listlength = int(raw_input("Enter the number of list elements >> "))
- listofnumbers = raw_input("Enter the list elements , space separated").split(" ")
- start = time.clock()
- total = Value('i',1)
- for i in range(listlength,1,-2):
- p = Process(target=check_values,args=(i,listofnumbers,listlength,total))
- p.start()
- p.join()
- print final
- print total.value
- print "Time : ",time.clock()-start
- except ValueError:
- print "Data not ok"
Advertisement
Add Comment
Please, Sign In to add comment