John Salerno wrote: > [EMAIL PROTECTED] wrote: > > > a = [0xf5fdc,0xf6edb,0xbddb7,0x6fddd,0xeb7ed,0xb977f,0xbfed3,0xedef5] > > b = [0xddb7d,0xfaddb,0xde75f,0xeef7a,0xdd77b,0xdfbce,0xb77dd,0x7ef5d] > > c = [0xf37bd,0xdfaee,0xddd6f,0xddfb6,0xb9efb,0xb7bbe,0xecfbd,0xb75df] > > d = [0x77edb,0xbb7ee,0xdf773,0x7bdeb,0x7ddaf,0xdeeeb,0xfb35f,0xbb7dd] > > > Once you see that a[0],b[0],c[0],d[0] is not a solution, try a > > different set of switches. Repeat until you find a set that works. > > There is, in fact a solution, but I won't reveal it unless you ask. > > Using your hex list, I combined the four correct switches with the & > operator, and the result was 0. Shouldn't it be 1 for the correct answer?
No. First of all, combining them with the & operator would be the asnswer to having all four lamps lit in the same position. But you want exactly 3 (in any combination). The correct way to combine the switches (using my answer of a[7] b[2] c[5] d[3]) is to use the boolean expression I gave you initially: >>> y = ((c[5] & d[3]) & (a[7] ^ b[2])) | ((a[7] & b[2]) & (c[5] ^ d[3])) >>> y 1048575 Note the answer is 2**20-1, not 1, the correct answer will have a 1 in EACH of the 20 bit positions (when y is printed in binary). Is 1048575 the right answer? >>> import gmpy >>> print gmpy.digits(y,2) 11111111111111111111 Yes, it is the right answer. If you calculate y for EVERY possible permutation of switches a[0] b[0] c[0] d[0] a[0] b[0] c[0] d[1] a[0] b[0] c[0] d[2] a[0] b[0] c[0] d[3] a[0] b[0] c[0] d[4] a[0] b[0] c[0] d[5] a[0] b[0] c[0] d[6] a[0] b[0] c[0] d[7] a[0] b[0] c[1] d[0] . . . a[7] b[7] c[7] d[5] a[7] b[7] c[7] d[6] a[7] b[7] c[7] d[7] you'll find that a[7] b[2] c[5] d[3] is the ONLY solution. -- http://mail.python.org/mailman/listinfo/python-list