size × size cells, numbered row by row from top to bottom and left to right: the cell in row r and column c has number r * size + c. A robot starts in cell 0, the top-left corner.
The robot carries out the commands in moves one by one: "UP" steps up, "DOWN" steps down, "LEFT" steps left and "RIGHT" steps right. It is guaranteed never to leave the grid.
Return the number of the cell where the robot ends up.size=3, moves=['RIGHT', 'RIGHT', 'DOWN'] → 5
From cell 0 the robot goes to 1, then 2, then one row down to cell 5.
size=4, moves=['DOWN', 'DOWN', 'RIGHT', 'UP', 'LEFT'] → 4
The path is 0 → 4 → 8 → 9 → 5 → 4.
"UP", "DOWN", "LEFT" or "RIGHT"size=3, moves=['RIGHT', 'RIGHT', 'DOWN']
5
Run checks the first 3 tests in your browser. Submit checks all 64 tests on the server, hidden ones included.