From 448403c922b7df672f955663dc4bb2cfa88ff652 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Thu, 22 Mar 2018 15:26:51 +0100 Subject: [PATCH] robota dodoano --- bin/robot.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bin/robot.rb diff --git a/bin/robot.rb b/bin/robot.rb new file mode 100644 index 0000000..10e9ad9 --- /dev/null +++ b/bin/robot.rb @@ -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 \ No newline at end of file