Lucid Software interview question

Implement the given code file