self moves list ""if self moves =[]return no states in self movesso do nothing self moves pop(remove the current state if self moves =[]self resetgrid(elseset the grid to the last move self grid copy copy(self moves[- ]def display(self)"""display the current state of the grid on the screen ""print( 'display column labels for in range(grid_length)for in range(grid_length)if = display row labelprint(str( 'end=''print(self grid[(xy)'end=''if = or = display vertical lineprint(''end=''print(print newline if = or = display horizontal lineprint(++'def _iscompletesetofnumbers(selfnumbers)"""return true if numbers contains the digits through ""return sorted(numbers=list(' 'def issolved(self)"""returns true if the current grid is in solved state ""check each rowfor row in range(grid_length)rownumbers [for in range(grid_length)number self grid[(xrow)rownumbers append(numberif not self _iscompletesetofnumbers(rownumbers)return false check each columnfor column in range(grid_length)columnnumbers [for in range(grid_length)number self grid[(columny)columnnumbers append(numberif not self _iscompletesetofnumbers(columnnumbers)return false sudoku puzzle