robota dodoano
This commit is contained in:
parent
03cc99720f
commit
448403c922
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/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
|
||||||
Loading…
Reference in New Issue