Постройте схему, взяв стартовый блок и попытавшись найти по горизонтали и вертикали другие блоки, которые не имеют значе ⇐ Python
Постройте схему, взяв стартовый блок и попытавшись найти по горизонтали и вертикали другие блоки, которые не имеют значе
from random import shuffle matrix_aux_with_num_decompositions = [ [None, 'b', None, 100, 100, -3], [None, None, 200, 'a', None, 100], [ 100, 200, None, None, None, None], ] matrix_aux_with_num_decompositions_aux = [ [ -1, 'asign', -3, 'asign', 'asign', -3], [ 5, 4, 'asign', 'asign', -2, 'asign'], ['asign', 'asign', -9, -3, -1, -5], ] #Possible coordinates of lockers that will function as starting points for the possible circuit #Note that they are the coordinates of the only positive values within the matrix called matrix_aux_with_num_decompositions_aux coords_posibles_elementos_de_partida = [ [1, 0], [1, 1] ] #optionally we can exchange the starting points to analyze them randomly shuffle(coords_posibles_elementos_de_partida) Try each of the boxes (given of the form [row, column]) in the list called coords_posibles_elementos_de_partida , until I get one that allows me to build a closed circuit, following the rule that can only extract data horizontally and vertically, and that must end where it started, that is, in the number of coordinates chosen from coords_posibles_elementos_de_partida The rest of the boxes, we will call them vertices, and they must be box values that are different from None and that are within the part of the matrix matrix_aux_with_num_decompositions
The circuits cannot have diagonal connections, and they must be closed, for example if it starts at [1, 0], a circuit that loops through values within matrix_aux_with_num_decompositions that are different from None and leaving them as vertices could be:
#This is a possible correct vertex list(output): circuit = [[1, 0], [1, 3], [0, 3], [0, 1], [2, 1], [2,0] ] and after [2, 0] it could return to [1, 0]
def is_valid_move(matrix, visited, row, col): # Check if the move is within the matrix boundaries and the cell is not visited return 0
Источник: https://stackoverflow.com/questions/781 ... ly-and-ver
from random import shuffle matrix_aux_with_num_decompositions = [ [None, 'b', None, 100, 100, -3], [None, None, 200, 'a', None, 100], [ 100, 200, None, None, None, None], ] matrix_aux_with_num_decompositions_aux = [ [ -1, 'asign', -3, 'asign', 'asign', -3], [ 5, 4, 'asign', 'asign', -2, 'asign'], ['asign', 'asign', -9, -3, -1, -5], ] #Possible coordinates of lockers that will function as starting points for the possible circuit #Note that they are the coordinates of the only positive values within the matrix called matrix_aux_with_num_decompositions_aux coords_posibles_elementos_de_partida = [ [1, 0], [1, 1] ] #optionally we can exchange the starting points to analyze them randomly shuffle(coords_posibles_elementos_de_partida) Try each of the boxes (given of the form [row, column]) in the list called coords_posibles_elementos_de_partida , until I get one that allows me to build a closed circuit, following the rule that can only extract data horizontally and vertically, and that must end where it started, that is, in the number of coordinates chosen from coords_posibles_elementos_de_partida The rest of the boxes, we will call them vertices, and they must be box values that are different from None and that are within the part of the matrix matrix_aux_with_num_decompositions
The circuits cannot have diagonal connections, and they must be closed, for example if it starts at [1, 0], a circuit that loops through values within matrix_aux_with_num_decompositions that are different from None and leaving them as vertices could be:
#This is a possible correct vertex list(output): circuit = [[1, 0], [1, 3], [0, 3], [0, 1], [2, 1], [2,0] ] and after [2, 0] it could return to [1, 0]
def is_valid_move(matrix, visited, row, col): # Check if the move is within the matrix boundaries and the cell is not visited return 0
Источник: https://stackoverflow.com/questions/781 ... ly-and-ver
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Перевернуть/отразить изображение по горизонтали и вертикали с помощью CSS
Anonymous » » в форуме CSS - 0 Ответы
- 43 Просмотры
-
Последнее сообщение Anonymous
-