solution to 1
solution for 2
solution for 3