Thought Machine interview question

To explain the code I wrote during the assignment