Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
mAlign solution in Clear category for Aggregate by Operation by veky
import collections
def aggr_operation(data: list[tuple[str, int]]) -> dict[str, int]:
C = collections.Counter()
for (op, *key), value in data:
if key := ''.join(key):
match op:
case '=': C[key] = value
case '+': C[key] += value
case '-': C[key] -= value
case '*': C[key] *= value
case '/':
if value: C[key] /= value
if not C[key]: del C[key]
return C
Aug. 21, 2022
Comments: