Advertisement
VssA

Untitled

Dec 7th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import multiprocessing
  2.  
  3.  
  4. def worker_function(list_of_int):
  5. result = 0
  6. for i in range(len(list_of_int)):
  7. result += list_of_int[i] ** i
  8. return result
  9.  
  10.  
  11. def process_array(list_of_lists):
  12. with multiprocessing.Pool() as pool:
  13. result = pool.map(worker_function, list_of_lists)
  14. return sum(result)
  15.  
  16.  
  17. if __name__ == "__main__":
  18. input_list = input()
  19. list_of_string_lists = input_list[1:len(input_list) - 1].split(", ")
  20. list_of_int_lists = []
  21. for list_str in list_of_string_lists:
  22. list_of_int_lists.append(list(map(int, list_str[1:len(list_str) - 1].split(' '))))
  23. print(process_array(list_of_int_lists))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement