Problem_45 solution