I think I know the reason you're program is crashing. As @dawkot already mentioned 246 is suspicious. This [issue](https://github.com/nim-lang/Nim/issues/12747) is relevant. Currently an array is always copied onto the stack when looping over it, which can be catastrophal. Inserting `echo sizeof(CoverMatrix)` explains the whole thing: CoverMatrix is 37 MB big, which floods the stack.
With a small modification it works: [https://play.nim-lang.org/#ix=26fC](https://play.nim-lang.org/#ix=26fC)
