[Tutor] Re: Tutor digest, Vol 1 #965 - 15 msgs

Christopher Smith csmith@blakeschool.org
Thu, 19 Jul 2001 12:03:01 -0500


Christopher P. Smith writes:
<cut>
>     m = nn/n + nn % n  # ceil(nn/n)

This should be the two lines
	m=(nn-nn%n)/n
	if (nn%n<>0):m=m+1

(You get the same with m=(nn-nn%/n)/n+(nn%n<>0), too, since logic results
are 0 or 1.
Watch out for division by zero, though.)

>     for i in range(n):
>         for j in range(i,i+m+n,n): # +m b/c you need that many past i 

And the range should be range(i,i+m*n,n)  #m*n not m+n

/c