Softwire Interview Question

Pseudo- coding, very logic based