problem 409
problem 349 with simulation