HakerRank part solution