Entitled:
Problem-solving ideas:
The new array is composed of: a new array for each column and the columns are the original array corresponding to the front row and the sum [1,2,3] ---> [1,3,6].
Each column is a crack in the wall, the more repeats of each column of numbers, the fewer wall wear!
Code:
Import numpy AS NP B = np.zeros (Shape = (l, 5), DTYPE = int) NP = np.random.randint (1,10, size = (5, 5 )) for I in np.T: B = + I m = len (SET (List (b.reshape (-1)))) - ##. 1 there is a problem here, because b is an Array, must reshape (-1) can look, see the following reasons Code! Print (m)
# Input: Import numpy AS NP X = np.random.randint (l, 5, size = (l, 5), DTYPE = int) X # Output: Array ([[. 1,. 3,. 1,. 3,. 1]] )
# Input: List (X) # Output: [Array ([ . 1,. 3,. 1,. 3,. 1 ])] # Input: x.reshape ( -1 ) # Output: Array ([ . 1,. 3,. 1,. 3, 1 ]) # input: list (x.reshape (-1 )) single-line array ## must reshape it, can list (), to give a regular list! # output: [ 1, 3, 1, 3, 1 ] # Therefore there can be re-set to: # input: sET (List (x.reshape ( -1 ))) # output: { 1, 3}
Topic algorithm: feeling very low
lst = [[1,2,2,1],[3,1,2],[1,3,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]] m = len(lst) lt = [] for i in lst: n=0 for j in i[:-1]: n+=j lt.append(n) lt1=[] for i in lt: lt1.append(lt.count(i)) y=m-max(lt1) print(y)