fork download
  1. from functools import reduce
  2. from itertools import product
  3. from operator import mul
  4.  
  5. p=[1,2,3]
  6. q=[6,5,4]
  7. r=[7,8,9]
  8.  
  9. def f(fn, *iterables):
  10. max_values = max(product(*iterables), key=lambda x: fn(*x))
  11. return fn(*max_values), max_values
  12.  
  13. max, pqr = f(lambda *args: reduce(mul, args), p, q, r)
  14. print(max)
  15. print(*pqr, sep=', ')
Success #stdin #stdout 0.04s 9404KB
stdin
Standard input is empty
stdout
162
3, 6, 9