I can’t get it( | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

I can’t get it(

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

18th Dec 2021, 8:29 PM
Timofey Ivanenko
Timofey Ivanenko - avatar
4 Antworten
+ 2
import numpy as np data = np.array([1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) row = int(input()) z = data.reshape(6, 5) print(z[row])
17th Nov 2022, 2:26 AM
Benjamin Fadina
Benjamin Fadina - avatar
+ 1
#in c++ it is for (int rows = 0; rows < 6; rows++) { for (int cols = 0; cols < 6; cols++) { cout << matrix[rows][cols] + 1;
16th Mar 2022, 10:12 AM
stephen mazola
stephen mazola - avatar
0
19th Jul 2022, 7:47 PM
Chanchal Shrivastava