Question: I have an array of arrays:

```
[
  [0,0,0,0],
  [0,1,0,0],
  [0,0,0,1],
  [0,0,0,0]
]

```

I want to find the index (row and column) of the items with value `1`. How can I do this? I need these values so that I can manipulate the cells at either side of the `1`s. I looked at `find.index` method, but I'm not sure.

Answer: 
Not that fancy, but you could use two loops:

```
ary = [
  [0, 0, 0, 0],
  [0, 1, 0, 0],
  [0, 0, 0, 1],
  [0, 0, 0, 0]
]

result = []
ary.each_with_index do |row, i|
  row.each_with_index do |value, j|
    result << [i, j] if value == 1
  end
end
result
#=> [[1, 1], [2, 3]]

```
Consider using the [Matrix](http://ruby-doc.org/stdlib-2.0.0/libdoc/matrix/rdoc/Matrix.html) class.

```
require 'matrix'

arr = [
  [0, 0, 0, 0],
  [0, 1, 0, 0],
  [0, 0, 0, 1],
  [0, 0, 0, 0]
]    

target = 1

Matrix[*arr].each_with_index.with_object([]) { |(e,row,col),a|
  a << [row,col] if e==target }
  #=> [[1, 1], [2, 3]]

```

I like how this reads.