# [SPOILER] Re: simultaneous assignment

Boris Borcic bborcic at gmail.com
Tue May 2 22:22:46 CEST 2006

```John Salerno wrote:
> bruno at modulix wrote:
>
>> Now if I may ask: what is your actual problem ?
>
> Ok, since you're so curious. :)
>
> Here's a scan of the page from the puzzle book:
> http://johnjsalerno.com/spies.png
>
> Basically I'm reading this book to give me little things to try out in
> Python. There's no guarantee that this puzzle is even conducive to (or
> worthy of) a programming solution.

def spyAreports(W,X,Y,Z) :
return W+X+Y == X+Y+Z == W+Z == 1*True

def spyBreports(W,X,Y,Z) :
return W+X+Y == X+Y+Z == W+Y+Z == 1*True

ft = (False,True)

possibilities =  [(W,X,Y,Z) for W in ft for X in ft for Y in ft for Z in ft]

def testReport(report,name) :
print name+"'s report",
n=sum(report(*possibility) for possibility in possibilities)
if n>0 :
if n == len(possibilities) :
print "must",
else :
print "may",
else :
print "can not",
print "be true"

testReport(spyAreports,"Spy A")
testReport(spyBreports,"Spy B")

```