solve problem 1 with python