# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import numpy as np mat=np.array([[12,8,7,10,12,6],[4,5,4,13,14,3],[4,3,6,11,12,5],[6,7,13,11,4,6],[10,13,13,4,6,3]]) tab=np.zeros((15)) def globalm(): tab=np.zeros((15)) for k in range(15): for i in range(mat.shape[0]): for j in range(mat.shape[1]): if mat[i,j]==k: tab[k]+=1 return tab def globalm2(): tab=np.zeros((15)) for i in range(15): tab[i]=np.sum(mat==i) return tab def uneligne(ligne): tab=np.zeros((15)) for i in range(15): tab[i]=np.sum(ligne==i) return tab def tousligne (): tab=uneligne(mat[0,:]) for i in range(1,mat.shape[0]): tab+=uneligne(mat[i,:]) return tab def propose(): tab=np.zeros((15)) for i in range(mat.shape[0]): for j in range(mat.shape[1]): tab[mat[i,j]]+=1 return tab