Inventia interview question

No proper interview, just a coding assignment to solve.