Elementum interview question

Typical coding interview puzzles.