Partition Problem

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Jul 24 03:45:18 EDT 2001


David Eppstein <eppstein at ics.uci.edu> wrote in news:eppstein-
E10BDA.10010023072001 at news.service.uci.edu:

> Nice, but shouldn't the len(seq)==1 test actually be <=1?
> The empty sequence has one permutation, not zero.

Oops. Missed that, thanks.

Tom_Good1 at excite.com (Tom Good) wrote in 
news:ac677656.0107230857.1a9a12be at posting.google.com:

> Bravo!  That's a good one.  When you say you prefer having the
> "return" in there, is your purpose to emphasize that execution does
> not "fall through" the first "yield"?

As I originally wrote it the return stopped it executing the main body and 
attempting to permute a 0 length sequence. Since I had written it so that 
permuting a 0 length sequence gave no permutations, this meant the return 
simply cut out a lot of code that had no net result. However, once it is 
fixed to correctly return one permutation of an empty sequence the return 
becomes essential.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list