HackerRank Python - Maximize It




You have to pick one element from each list so that the value from the equation below is maximized:



  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. from itertools import product
  3. k, m = map(int, input().split())
  4. array = []
  5. for _ in range(k):
  6. array.append(list(map(int, input().split()))[1:])
  7. result = 0
  8. for combination in product(*array):
  9. result = max(sum([x * x for x in combination]) % m, result)
  10. print(result)




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube