solutions from codility.com/train/