BIS SOFT interview question

A problem related to find an algorithm to some logic.