Solve second HackerRank FP challenge