Hi,
There is a function 'time' in the core of clojure, so I always use it to test my codes' time costs.
I think it's more accurate than ideone's estimation method, therefore the 2.05s on ideone may just cost hundreds of msecs.
If you really want to know my method, it's just based on an obvious observation.
The original idea to the problem is to check all the matrices the square contains.
But in fact, to the big data, most of the matrices doesn't contribute to the answer, they are redundant.
So in order to decrease the time, you can just check some of the matrices.
Then there is a question. How to know which set of matrices we need?
If you have some experience in random algorithm, that's it.
Yours.