I tried hard but can't solve this problem . So help me out . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

7th Oct 2021, 6:34 AM
Bobby
6 Answers
+ 2
print(data.reshape(6,5)[row])
7th Oct 2021, 8:23 AM
Simba
Simba - avatar
+ 4
Bobby , you should reshape the array. Look at the code. https://code.sololearn.com/cZuNO4cqHsMw/?ref=app
7th Oct 2021, 6:46 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
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
7th Oct 2021, 8:26 AM
Rik Wittkopp
Rik Wittkopp - avatar
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"); }
19th Feb 2023, 4:22 PM
Gilbert Cañedo Jr
Gilbert Cañedo Jr - avatar
0
Ahh never mind I thought it's a Java Programming language My bad.
19th Feb 2023, 4:27 PM
Gilbert Cañedo Jr
Gilbert Cañedo Jr - avatar
- 1
TheWh¡teCat 🇧🇬 Bro it's not working
7th Oct 2021, 7:27 AM
Bobby