Softwire interview question

Pseudo- coding, very logic based