problem 2 solve with generator yield