Wix Studio can model editor interactions on a bounded square grid. Given an N x N grid, a starting cell, an initial facing direction, and a command sequence, compute the final position and facing direction.
Commands have the following meanings:
F: Move forward one cell. If the next cell is outside the grid, remain in the current cell.L: Turn 90 degrees left without changing position.R: Turn 90 degrees right without changing position.Use zero-based coordinates, where (0, 0) is the northwest corner. Directions are represented by N, E, S, and W.
Implement final_position(n, start, direction, commands):
n is an integer grid size.start is a two-element list [row, column].direction is one of N, E, S, or W.commands is a string containing only F, L, and R.row, col, and direction.def final_position(n, start, direction, commands):