Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 22, 2021 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/77267bb04664355d3e078746355201fe to your computer and use it in GitHub Desktop.
Save parzibyte/77267bb04664355d3e078746355201fe to your computer and use it in GitHub Desktop.
def todos_los_barcos_hundidos(matriz):
for y in range(FILAS):
for x in range(COLUMNAS):
celda = matriz[y][x]
# Si no es mar o un disparo, significa que todavía hay un barco por ahí
if celda != MAR and celda != DISPARO_ACERTADO and celda != DISPARO_FALLADO:
return False
# Acabamos de recorrer toda la matriz y no regresamos en la línea anterior. Entonces todos los barcos han sido hundidos
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment