Moody's interview question

Coding by hand, general questions, logic questions