# ==============================================================================
"""EXERCICE 1"""
# ==============================================================================
__author__  = "Philippe Blasi"
__version__ = "1.0"
__date__    = "2026-03-27"
__usage__   = """
User input : <nb_row>,<nb_col> (where n:int >= 0, p:int >= 0)
App output : two matrices"""
# ==============================================================================
# -------------------------------------------------------------------
from ezCLI import *
# -------------------------------------------------------------------
def f1(nb_row, nb_col):
    mat = [[row+col for col in range(nb_col)] for row in range(nb_row)]
    for row in range(nb_row//2):
        for col in range(nb_col):
            if col >= nb_col//2:
                mat[row][col] = mat[row][nb_col-col-1]
    return mat
# -------------------------------------------------------------------
def f2(mat):
    nb_row, nb_col = len(mat), len(mat[0])
    for row in range(nb_row//2):
        for col in range(nb_col):
            mat[row][col],mat[nb_row-row-1][nb_col-col-1] = mat[nb_row-row-1][nb_col-col-1], mat[row][col]
    return mat
# -------------------------------------------------------------------
# Question A : exécuter le code pour voir
# Question B : f1 crée une matrice de nb_row lignes et nb_col colonnes. Chaque case[row][col]
#              contient la somme des deux indices, puis pour les première moitié de la matrice
#              rend les lignes symétriques
#              f2 inverse l'odre des lignes de la matrice
# Question C : aucun problème 
# Question D : on se contente de recopier et modifier le parser de l'exercice bino
# ------------------------------------------------------------------------------
def parser(command:str) -> str:
  """parse 'command' as 'nb_row,nb_col' before calling 'f1(nb_row, nb_col) and f2(mat)'"""
  command = convert(command)
  assert type(command) is tuple and len(command) == 2, "invalid syntax"
  nb_row, nb_col = command
  assert type(nb_row) is int and nb_row >= 0, "<nb_row> must be a positive integer"
  assert type(nb_col) is int and nb_col >= 0, "<nb_col> must be a positive integer"
  mat = f1(nb_row, nb_col)
  grid_f1=grid(mat)
  grid_f2=grid(f2(mat))
  return f"{grid_f1}\n{grid_f2}"
# ==============================================================================
if __name__ == '__main__':
  userloop(parser, "Enter <nb_row>,<nb_col>")
# ==============================================================================
