working grid product solver; looks more like C than ruby but oh well, it's fast and iterative