HackerRank- sherlock and square (difficult)