Added solutions for the fourth problem in C, Haskell, Java and Python