+ 1
I tried hard but can't solve this problem . So help me out .
You are given an array that represents the occupancy of seats in a movie theater. A seat marked with 1 is occupied, while one marked 0 means the seat is free. However, the array is flat and 1-dimensional. Transform it into a 2-dimensional array, representing the rows of the seats. Each row in the theater has 5 seats and there are a total of 30 seats. Reshape the array into the corresponding shape and output the row at the given index, which is taken from user input. https://code.sololearn.com/cJhwPhrZ1SSk/?ref=app
6 Respuestas
+ 2
print(data.reshape(6,5)[row])
+ 4
Bobby , you should reshape the array. Look at the code.
https://code.sololearn.com/cZuNO4cqHsMw/?ref=app
0
Bobby
TheWh¡teCat 🇧🇬 has shown you how to reshape the single dimension array into a multi-dimension array.
Now you need to do basic list slicing as per your previous learning.
The challenge states:
You are given an array that represents the occupancy of seats in a movie theater. A seat marked with 1 is occupied, while one marked 0 means the seat is free.
However, the array is flat and 1-dimensional. Transform it into a 2-dimensional array, representing the rows of the seats.
Each row in the theater has 5 seats and there are a total of 30 seats.
Reshape the array into the corresponding shape and output the row at the given index, which is taken from user input.
In your code, row = int(input())
This specifies user index, now apply it to your data array
0
int x = 0;
int cols = sc.nextInt();
int rows = sc.nextInt();
for(int c = 0; c< seats.length; c++){
for(int r = 0; r<seats[c].length;r++){
x = seats[cols][rows];
}
}
if(x == 0){
System.out.println("Free");
}
else if(x==1){
System.out.println("Sold");
}
0
Ahh never mind I thought it's a Java Programming language My bad.
- 1
TheWh¡teCat 🇧🇬 Bro it's not working