You can avoid the nested loops by using `repeated_permutation`, which will give you exactly the same combinations of `n` and `x` as nesting `each`.

```ruby
[1, 4, 7].repeated_permutation(2).each do |n, x|
  subgrids << subgrid(n, x)
end
```

If you combine that with `map` you can also remove both the first and the last lines of the method.

```ruby
[1, 4, 7].repeated_permutation(2).map do |n, x|
  subgrid(n, x)
end
```