Guest User

Untitled

a guest
Mar 30th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import time
  2. from multiprocessing import Process,Lock,Pool
  3. from multiprocessing.sharedctypes import Value
  4. final = []
  5. def check_values(i,listofnumbers,listlength,total):
  6. for i1 in range(0,listlength + 1 - i):
  7. numbers = []
  8. countofnumbers=[]
  9. currentlist = listofnumbers[i1:listlength-abs(i-listlength+i1)]
  10. #print "I:",i,",TR nIZ ",tr_niz
  11. for k in currentlist:
  12. if k not in numbers:
  13. numbers.append(k)
  14. countofnumbers.append(currentlist.count(k) if currentlist.count(k)%2==0 else 0)
  15. if 0 not in countofnumbers:
  16. if sum(countofnumbers)%2==0:
  17. print "Hello"
  18. total.value+=1
  19.  
  20.  
  21. try:
  22. listlength = int(raw_input("Enter the number of list elements >> "))
  23. listofnumbers = raw_input("Enter the list elements , space separated").split(" ")
  24. start = time.clock()
  25. total = Value('i',1)
  26. for i in range(listlength,1,-2):
  27. p = Process(target=check_values,args=(i,listofnumbers,listlength,total))
  28. p.start()
  29. p.join()
  30. print final
  31. print total.value
  32. print "Time : ",time.clock()-start
  33.  
  34. except ValueError:
  35. print "Data not ok"
Advertisement
Add Comment
Please, Sign In to add comment