@shirleyquick .. interesting ... but it's too complex for me ... (but I will dive into template, and types)
Here is my optimized version (adding just an "unik" method) and it resolves 1011 grids ... in less time than yours ;-) <https://play.nim-lang.org/#ix=3CGf>