This is a simple Java application that solves provided problem: https://www.codeeval.com/public_sc/49