think-cell interview question

Programming tasks via codepad, no stl is needed or allowed.