• + 1 comment

    I wonder what the time limit/estimate for a single 30x30 matrix in Python 3 is.

    I used a single bytes sequence to store the matrix' bits (rows first), so I would only need to split it once to make a horizontal cut. For the vertical cuts I transposed the matrix first, so that would only need to be cut once.

    I cached the already found Grundy numbers in a dict, so I wouldn't need to traverse them again.

    So far, I got it down to a consistent 7.3 s on a random matrix on my machine, but that still fails tests 3 and 4. I ran out of ideas.

    Should I be using a different data structure? I tried the same algorithm, but storing data as an integer, setting the individual bits, but that turned out to be way slower.