This is a problem that I have solved in one of my previous coding test. To see details please read the problem-definitions.md