I developed a still shorter version. Obviously, the procedure which it and the previous describe are composed of distinct concepts; one or the other may be more intuitive for any given programmer. This formula can be used directly in an expression, rather than requiring a loop; it has no side effects.
Again, for R = # of rows, N = # of windows, we have:
cols= int( math.ceil( float( N )/ R ) )
rows0= int( math.floor( float( N )/ cols ) )
remainder= N% ( rows0* cols )
WpC= [ rows0 ]* ( cols- remainder )+ [ rows0+ 1 ]* remainder
The 'rows' variable is distinguished by a '0' because there are really two 'rows' quantities involved: rows0 and rows0+ 1. Specifically, the smaller value begins the list, repeated 'cols- remainder' number of times; then the larger value is repeated 'remainder' number of times.
We notice 'rows0' has already incremented to the next larger value for N equal to an integral multiple of R, with no remainder!