TheoremOne interview question

Project based interview took a long time