[Tutor] Is there a better way to do this?
Alan Gauld
alan.gauld at blueyonder.co.uk
Thu Jul 22 23:08:54 CEST 2004
This might help:
> c = 1
> for p0 in range(0, 7):
> for p1 in range(p0, 12):
> for p2 in range(p1, 12):
> for p3 in range(p2, 12):
> for p4 in range(p3, 12):
> for p5 in range(p4, 12):
> print repr(c).rjust(3), "\t",
> print "%X %X %X %X %X %X" % (p0, p1, p2, p3, p4, p5)
> c += 1
Not sure what the c increment does but I'll leave it in!
> print "...Done"
Ultimately you have to generate all the permutations but by
eliminating
the ones you already know are invalid it should speed it up a bit.
Alan G.
More information about the Tutor
mailing list