# ==============================================================================
from ezCLI import *
# ==============================================================================

# ------------------------------------------------------------------------------
# Question A : recopier la première ligne de la fonction f1 de l'exercice 1 et
# mettre value dans chaque case à la place de la somme
# ------------------------------------------------------------------------------

def get_mat(nb_row:int,nb_col:int,value) -> list:
  return [[value for col in range(nb_col)] for row in range(nb_row)]

# ------------------------------------------------------------------------------
# Question B
# ------------------------------------------------------------------------------

def grid2str(tab:list)-> str:
  t = [''.join(l) for l in tab]
  return '\n'.join(t)

# ------------------------------------------------------------------------------
# Question C
# ------------------------------------------------------------------------------

def right_rectangle(nb_col:int=12, nb_row:int=9,symbol:str='#') -> None:
  tab = get_mat(nb_row,nb_col,' ')
  # ----------------------------------------------------------------------------
  for row in range(nb_row):
    for col in range(min(row+1,nb_col)):
      tab[row][col] = symbol

  return grid2str(tab)

# ------------------------------------------------------------------------------
# Question D
# ------------------------------------------------------------------------------

def isosceles_triangle(nb_row:int,nb_col:int,symbol:str='#') -> None:
  tab = get_mat(nb_row,nb_col,' ')
  # ----------------------------------------------------------------------------
  middle = nb_col//2
  for row in range(nb_row):
    for col in range(max(0,middle-row),min(middle+row+1,nb_col)):
      tab[row][col] = '#'

  return grid2str(tab)

# ------------------------------------------------------------------------------
# ==============================================================================
if __name__ == "__main__":
  print(right_rectangle(5,9))
  print()
  print(right_rectangle(8,6))
  print()
  print(isosceles_triangle(5,11))
  print()
  print(isosceles_triangle(9,9))
# ==============================================================================
