Meta interview question

Can you write a script to solve this problem