problem 5 solution added, problem 4 solved with linq