a problem to solve
mensanator at aol.com
mensanator at aol.com
Sat Mar 25 07:51:50 CET 2006
John Salerno wrote:
> John Salerno wrote:
> > mensanator at aol.com wrote:
> >
> >> 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:
> >
> > Ah, that makes sense. I think I have a handle on it now. Of course, you
> > did the grunt work of making the hex list, which might not have been so
> > fun, but now I can work on using it to get the solution. Once I do, I'd
> > love to compare my answer to yours, because something tells me yours
> > will be much more elegant. :)
>
> p.s. is there an xor operator in python?
Yep. The XOR operator is ^. That's why you have to use **
for exponentiation. In addition to &=AND, there is also
|=OR. I actually gave two boolean expressions.
First, using the standard notation, where concatenation implies
AND, + is OR and x is XOR (actually, the standard notation
for XOR is a + inside a circle, but my keyboard doesn't have
one of those).
Y = CD(A x B) + AB(C x D)
Second, using the Python operators
Y = ((C & D) & (A ^ B)) | ((A & B) & (C ^ D))
More information about the Python-list
mailing list