Brainium Studios interview question

Implement an algorithm for UI purposes.