Art & Logic interview question

2 part coding question, followed by an essay section.