def __init__(self, rens, cols, generacion, poblacion): self.largo = rens self.ancho = cols self.grid = Array2D(self.largo, self.ancho, 0) self.generacion = generacion for celula in poblacion: self.grid.set_item(celula[0], celula[1], self.celula_viva)
def __init__(self , rens , cols , pasillos , entrada , salida): self.__laberinto = Array2D(rens , cols , '1') for pasillo in pasillos: self.__laberinto.set_item(pasillo[0] , pasillo[1] , '0') self.set_entrada(entrada[0], entrada[1]) self.set_salida(salida[0], salida[1]) self.__camino = Stack() self.__previa = None
def __init__(self, nrows, ncols): self._nRows = nrows self._nCols = ncols # The 2D array to store the individual pixels. self._the2DArray = Array2D(self._nRows, self._nCols) self.clear(_RGBColor())
def __init__(self, rens, cols, generaciones, poblacion): self.largo = cols self.alto = rens self.grid = Array2D(self.alto, self.largo, 0) self.generaciones = generaciones for celula in poblacion: # recorre el eje x & y self.grid.set_item(celula[0], celula[1], self.CELULA_VIVA)
def __init__(self, numRows, numCols): # Allocate the 2-D array for the grid. self._grid = Array2D(numRows, numCols) # Clear the grid and set all cells to dead. self.configure(list())
def __init__(self): self._theBoard = Array2D(3, 3) self._moves = list() self._markBoard() self.currentWinner = None self.count = 0
def __init__(self, numRows, numCols): self._mazeCells = Array2D(numRows, numCols) self._startCell = None self._exitCell = None
# Since we have multiple grades for multiple students, we can store the grades in a 2-D array in which each # row contains the grades for an individual student and each column contains the grades for a given exam. from array2D import Array2D fileName = "C:\\Users\\user\\Desktop\\studentsExams.txt" # Open the text file for reading. gradeFile = open( fileName, "r") # Extract the first two values which indicate the size of the array. numExams = int( gradeFile.readline() ) numStudents = int( gradeFile.readline() ) # Create the 2-D array to store the grades. examGrades = Array2D( numStudents, numExams ) # Extract the grades from the remaining lines. i = 0 for student in gradeFile : grades = student.split() print( grades ) for j in range( numExams ) : examGrades[ i, j ] = int( grades[j] ) i += 1 # Close the text file. gradeFile.close() # With the grades extracted from the file and stored in the 2-D array, we can now process the grades as needed.
def __init__(self, nrows, ncols): assert nrows > 0 and ncols > 0, 'number of rows or cols must be greater than 0!' self._grid = Array2D(nrows, ncols) self.configure(list())
def __init__(self, n): self._theBoard = Array2D(n, n) self._rowSize = n self._size = n * n self._numQueens = 0 self._count = 0
def __init__( self, nrows, ncols ) : self._thePixels = Array2D( nrows, ncols ) self._thePixels.clear( 0 )
def __init__(self, numRows, numCols): self.grid = Array2D(numRows, numCols) self.grid.clear(0)
def __init__(self, numRows, numCols): assert numRows >= 0 and numCols >= 0, "The matrix must have numRows >= 0 and numCols >= 0." self._theGrid = Array2D(numRows, numCols) self._theGrid.clear(0) # initialize with all zeros
def __init__(self, numRows, numCols): self._theGrid = Array2D(numRows, numCols) self._theGrid.clear(0) # Define all the 0 values - Array2D method
def __init__(self, rows, cols): self._matrix = Array2D(rows, cols) self._matrix.clear(0)
def __init__(self, rens, cols, pasillos): self.__laberinto = Array2D(rens, cols, '1') for pasillo in pasillos: self.__laberinto.se_item(pasillo[0], pasillo[1], '0')