Apr-24-2020, 12:21 PM
Hello guys,
I need your help to solve this problem. I need to print a rectangle inside an another rectangle.
Example :
Input :
9 19 (number of lignes of ".", number of column of ".")
1 (number of rectangle inside)
1 3 7 5 o (lig1, col1, lig2, col2, caracter)
Output :
...................
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...................
1) Method 1 that I tried :
9 19
1
output :
...................
...................
...................
...................
...................
...................
...................
...................
...................
I don't know how to add the second rectangles inside the first one according to the parameter we specify in the input (1 3 7 5 o). Does anyone have an idea how to do it please ?
2) Method 2 that I tried :
I tried an another version without multidimensional array but I don't know if it's the right method.
9 19
1
1 3 7 5 o
Output :
...................
...................
...................
...................
...................
...................
...................
...................
...................
oo
oo
oo
oo
oo
oo
Thank you for your help
I need your help to solve this problem. I need to print a rectangle inside an another rectangle.
Example :
Input :
9 19 (number of lignes of ".", number of column of ".")
1 (number of rectangle inside)
1 3 7 5 o (lig1, col1, lig2, col2, caracter)
Output :
...................
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...ooo.............
...................
1) Method 1 that I tried :
nbLignes, nbColonnes = map(int, input().split(" ")) nbRectangles = int(input()) tab = [ ["."] * nbColonnes] * nbLignes for i in range(len(tab)): for j in range(len(tab[i])): print(tab[i][j], end="") print()input :
9 19
1
output :
...................
...................
...................
...................
...................
...................
...................
...................
...................
I don't know how to add the second rectangles inside the first one according to the parameter we specify in the input (1 3 7 5 o). Does anyone have an idea how to do it please ?
2) Method 2 that I tried :
I tried an another version without multidimensional array but I don't know if it's the right method.
nbLignes, nbColonnes = map(int, input().split(" ")) nbRectangles = int(input()) for loop in range(nbRectangles): lig1, col1, lig2, col2, couleur = input().split(" ") for i in range(nbLignes): for j in range(nbColonnes): print(".", end ="") print() for i in range(int(lig1), int(lig2)): for j in range(int(col1), int(col2)): print(couleur, end = "") print()Input :
9 19
1
1 3 7 5 o
Output :
...................
...................
...................
...................
...................
...................
...................
...................
...................
oo
oo
oo
oo
oo
oo
Thank you for your help