[Python3] brute-force
Please check out this commit for solutions of weely 273. \n\n\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[i
Please check out this [commit](https://github.com/gaosanyong/leetcode/commit/338b3e50d12cc0067b8b85e8e27c1b0c10fd91c6) for solutions of weely 273. \n\n```\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        ans = []\n        for k in range(len(s)): \n            i, j = startPos\n            val = 0 \n            for kk in range(k, len(s)): \n                if s[kk] == \'L\': j -= 1\n                elif s[kk] == \'R\': j += 1\n                elif s[kk] == \'U\': i -= 1\n                else: i += 1\n                if 0 <= i < n and 0 <= j < n: val += 1\n                else: break \n            ans.append(val)\n        return ans \n```\n\n```\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        \n        @cache\n        def fn(i, j, k): \n            """Return valid number of instructions at (i, j) starting from kth."""\n            if k == len(s): return 0 \n            if s[k] == \'L\': j -= 1\n            elif s[k] == \'R\': j += 1\n            elif s[k] == \'U\': i -= 1\n            else: i += 1\n            if 0 <= i < n and 0 <= j < n: return 1 + fn(i, j, k+1)\n            return 0 \n        \n        return [fn(*startPos, k) for k in range(len(s))]\n```
['Python3']