Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 22, 2021 04:25
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/a061c0aef35806c58ae0ce879fabac24 to your computer and use it in GitHub Desktop.
Save parzibyte/a061c0aef35806c58ae0ce879fabac24 to your computer and use it in GitHub Desktop.
def imprimir_matriz(matriz, deberia_mostrar_barcos, jugador):
print(f"Este es el mar del jugador {jugador}: ")
letra = "A"
for y in range(FILAS):
imprimir_separador_horizontal()
print(f"| {letra} ", end="")
for x in range(COLUMNAS):
celda = matriz[y][x]
valor_real = celda
if not deberia_mostrar_barcos and valor_real != MAR and valor_real != DISPARO_FALLADO and valor_real != DISPARO_ACERTADO:
valor_real = " "
print(f"| {valor_real} ", end="")
letra = incrementar_letra(letra)
print("|",) # Salto de línea
imprimir_separador_horizontal()
imprimir_fila_de_numeros()
imprimir_separador_horizontal()
def incrementar_letra(letra):
return chr(ord(letra)+1)
def imprimir_separador_horizontal():
# Imprimir un renglón dependiendo de las columnas
for _ in range(COLUMNAS+1):
print("+---", end="")
print("+")
def imprimir_fila_de_numeros():
print("| ", end="")
for x in range(COLUMNAS):
print(f"| {x+1} ", end="")
print("|")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment