Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part III: Move Starman Down (15 points) Write a function move-dwn ( ) that takes

ID: 3595682 • Letter: P

Question

Part III: Move Starman Down (15 points) Write a function move-dwn ( ) that takes one argument, board, which represents the current state of the game board. Your function should move Starman down by one row, update the game board (if needed), and then return Starman's new location as [row number, column number Please note that these are the real row and column numbers, not the indexes in the board list. Special rules apply: please check General Tasks for Parts II through V above. Examples: board! [[,.,, ,.,, ,.,, ,.,, ,W'), board2 [[,.,, ,.,, ,.,, ,F, , ,.,), CSE 101 - Fall 2017 Homework #3 Page 5 board3 [[,.,, ,0, ,.,, ,.,, ,.,), , Return Value Function Call move.down (boardl) [3, 2] move.down (board2)-1, -1] move.down (board)[4, 2] Updated boards: board! [[,.,, ,.,, ,.,, ,.,, ,W'), board2 [[,.,, ,.,, ,.,, ,F, , ,.,), board3 [[,.,, ,0, ,.,, ,.,, ,.,), ,

Explanation / Answer

def move_down(board):
for i in range(len(board)):
for j in range(len(board[i])):
if board[i][j] == '*':
board[i][j] = '.'
if i+1 < len(board):
board[i+1][j] = '*'
return (i+2, j+1)
return (i+1, j+1)

board1 = [['.', '.', '.', '.', 'W'],
['.', '*', '.', '.', '.'],
['.', 'F', 'O', 'F', '.'],
['.', '.', 'O', '.', 'W'],
['.', '.', 'O', '.', '.']]
print(move_down(board1))
print(board1)

# copy pastable code link in case indentation mess up: https://paste.ee/p/yENkN