Mr. Cooper interview question

Long machine coding to show output in terminal