Last active
July 26, 2020 23:58
-
-
Save renatojobal/320008ddf485c634ba6b8e7f12f836b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_matriz_full(matriz): | |
""" | |
Funcion principal que recibe como parámetro una matriz. | |
Recorremos cada fila y luego por cada elemento de la fila llamamos a la | |
función 'is_repeated_value_in_row'. | |
""" | |
for row in matriz: | |
for item in row: | |
if is_repeated_value_in_row(row, item): | |
return "Si" | |
return "No" | |
def is_repeated_value_in_row(array, target_value): | |
""" | |
Esta función recibe comop parámetro un arreglo (array) y un valor (target_value) | |
Devuelve True cuando el valor pasado se encuentra 4 o más veces dentro del arreglo. | |
""" | |
count = 0 | |
fount = False | |
for item in array: | |
if target_value == item: | |
fount = True | |
count += 1 | |
else: | |
if fount: | |
return False | |
return count >= 4 | |
def test(): | |
matriz = [[1, 2, 5, 7, 11], | |
[6, 3, 1, 3, 3], | |
[9, 7, 2, 1, 10], | |
[13, 1, 13, 1, 13], | |
[8, 9, 11, 12, 1]] | |
print(is_matriz_full(matriz)) | |
x = input() | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment