The solution I submited for the Vox Codei codingame challenge
By chatting or signing in you agree to the Terms and chat-message logging (revocable in History).