Python Forum

Full Version: How many times does it fit? help please
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What im trying to do is to check how many times does an 1x1 slice fits in the entire array, i used slice to get array "fragments" but how to check how many times that fragment fits inside the entire array?
the 1x1 fits 64 times, 2x2 16.....
Tablero means board, by uxu i mean 1x1, dxd = 2x2....
import numpy as np

tablero = np.zeros((8,8))
print(tablero)

uxu = tablero[0:1,0:1]
print(uxu)

dxd = tablero [0:2,0:2]
print (dxd)

txt = tablero [0:3,0:3]
print (txt)
Solved, left the code here if someone would like to see it
Grande=Big
Chica=Small
Filas=Rows
Columnas=Columns
Entra=Fits
Veces=Times
maybe those few word translations will be useful :)
import numpy as np
nGrande = 8
matrizGrande = np.zeros((nGrande,nGrande))
for i in range(1,matrizGrande.shape[0]+1):
    matrizChica = np.zeros((i,i))
    filasMatriz = matrizChica.shape[0]
    columnasMatriz = matrizChica.shape[1]
    entra = matrizGrande.shape[0]//filasMatriz * matrizGrande.shape[0]//columnasMatriz
    print("La Matriz de",str(i)+"x"+str(i)+" entra",entra, "veces en la matriz de",str(matrizGrande.shape[0])+"x"+str(matrizGrande.shape[0]))
Number of times the small list S[row,col] fits in the Big list A[bRow,bCol] is equal to:
(bRow * bCol)/(row * col)
Hope you get the idea..