set partitioning
aaronwmail-usenet at yahoo.com
aaronwmail-usenet at yahoo.com
Mon May 1 18:22:01 EDT 2006
Something like this, or am I missing something?
def partition(List, n, m, k):
if n!=m*k:
raise "sorry, too many or too few elts"
D = {}
for x in List:
D[x] = 1
if len(D)!=n:
raise "sorry (2) you lied about the number"
List2 = D.keys()
result = []
for i in range(m):
result.append( List2[i*k: i*k+k] )
return result
?
If this was a take home exam problem,
you should be ashamed of yourself!
-- Aaron Watters
===
It's easy. All you have to do is hit
the right keys at the right time and
the organ plays itself. -- J.S. Bach
More information about the Python-list
mailing list