This relates to the sherlock problem on https://www.hackerrank.com/contests/sep13/challenges/sherlock-and-the-beast