TripleDart interview question

I got an assignment for the same.