Use generators and the sum builtin