Simple Solution
\n# Code\nruby []\n# @param {Integer} n\n# @param {Integer[]} start_pos\n# @param {String} s\n# @return {Integer[]}\ndef execute_instructions(n, start_pos, s)\n
\n# Code\n```ruby []\n# @param {Integer} n\n# @param {Integer[]} start_pos\n# @param {String} s\n# @return {Integer[]}\ndef execute_instructions(n, start_pos, s)\n    @matrix = Array.new(n) { Array.new(n) {true} }\n    @start_pos = start_pos\n    answer = []\n    i = 0\n    while i < s.size\n        answer << move_robo(s, i)\n        i += 1\n    end\n    \n    answer\nend\n\ndef move_robo s, i\n    answer = 0\n    y, x = @start_pos\n    while i < s.size\n        case s[i]\n        when "R"\n            x += 1\n        when "D"\n            y += 1\n        when "U"\n            y -= 1\n        when "L"\n            x -= 1\n        end\n\n        if @matrix[y] and @matrix[y][x] and x > -1 and y > -1\n            answer += 1\n        else\n            break\n        end\n\n        i += 1\n    end\n\n    answer\nend\n```
['Ruby']