Star Systems Interview Question

they given a case to solve it programatically