Adding the final solutions for tasks 2, 3 and 4