FinYX interview question

implement missing logic in existing code