Ingenuity Gaming interview question

Aptitude, Logical, Programming , Code