fork download
  1. from functools import reduce
  2.  
  3. def f(x):
  4. out = []
  5.  
  6. for i, _ in enumerate(x):
  7. out.append(reduce(lambda p, q: p * q, x[:i] + x[i+1:]))
  8. return out
  9.  
  10. print(f([1, 7, 3, 4]))
  11. assert f([1, 7, 3, 4]) == [84, 12, 28, 21]
  12.  
Success #stdin #stdout 0.03s 9072KB
stdin
Standard input is empty
stdout
[84, 12, 28, 21]