Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- from math import floor, ceil
- def round_by_mask(a, mask):
- return [f(x) for x, f in zip(a, mask)]
- def my_round(a):
- need = round(sum(a) + 1e-6)
- for mask in itertools.product([floor, ceil], repeat=2):
- r = round_by_mask(a, mask)
- if sum(r) == need:
- return need, r
Advertisement
Add Comment
Please, Sign In to add comment