27 lines
978 B
Ruby
27 lines
978 B
Ruby
#!/usr/bin/env ruby
|
|
# encoding: UTF-8
|
|
|
|
@table = [
|
|
['0','0','0','0','0','0','0','0','0','0','0','0','0'],
|
|
['0','1','1','1','1','1','1','1','1','0','0','0','0'],
|
|
['0','0','1','0','0','0','1','0','1','1','0','0','0'],
|
|
['0','1','1','0','0','1','0','0','0','1','1','0','0'],
|
|
['0','1','1','1','1','1','1','1','1','0','1','0','0'],
|
|
['0','0','0','0','0','0','0','0','1','0','1','0','0'],
|
|
['0','1','1','1','1','1','1','0','1','0','1','0','0'],
|
|
['0','1','0','0','0','0','1','0','1','0','1','0','0'],
|
|
['0','1','1','1','1','0','1','0','1','0','1','0','0'],
|
|
['0','S','1','0','1','0','1','1','1','0','1','1','1'],
|
|
['0','0','0','0','0','0','0','0','0','0','0','0','0']
|
|
]
|
|
|
|
def find_start_pos(table, start_symbol='S')
|
|
table.each_with_index { |row,index_row|
|
|
row.each_with_index { |cell,index_cell|
|
|
return [index_row, index_cell] if cell.eql?(start_symbol)
|
|
}
|
|
}
|
|
return nil
|
|
end
|
|
|
|
puts find_start_pos(@table).inspect |