This is the solution to Codility's TimeEquilibrium question.