Turing interview question

Solve the coding in 20 minutes.