CS 0008: Spring 2015 Lab 4 YOUR NAME: YOUR PARTNER'S NAME: **** Booleans and the Poisonous Potions Problem Remember: a and b and c and d is True only if ALL of a, b, c, d are True is False if ANY of a, b, c, d is False a or b or c or d is False only if ALL of a, b, c, d are False is True if ANY of a, b, c, d is True This part of your lab is about a logic puzzle involving four potions. You don't know which, if any, of the potions are poisonous, but you are given five hints: 1. At least one of the four potions is poisonous 2. p2 is not poisonous 3. At least one of p1 and p3 is poisonous 4. At least one of p3 and p4 is not poisonous 5. Exactly one of p1, p3, and p4 is poisonous Download puzzle.py from the course schedule. We use four boolean variables p1 to p4 to represent the potions: a True value means that the potion is poisonous, and a False indicates that it is not. The first hint in has been translated into a Python function for you in puzzle.py hint1(False,False,False,False) will return False. This means that it isn't possible for all of the potions to not be poisonous, because then hint1 would be violated. However, hint1(False,True,False,True) will return True, meaning that p2 and p4 being poisonous, and p1 and p3 not being poisonous, will satisfy the first hint. However, the solution has to satisfy all five hints simultaneously. That's what function 'solution' tests - that all five hints are satisfied. If you give it a potential solution, such as False, True, True, False, it will return True if all five hints are satisfied, and False otherwise. Of course, it doesn't work yet -- you need to finish writing the other four hint functions. Once you are finished, call 'solution' with a solution. Trace the code in the debugger or on paper, and make sure you understand why h1, h2, h3, h4, h5 have the values they do. Also, make sure you know why "solution" returns what it does. Now, try to figure out a solution (there is more than one!) How do you do that? You reason like this, for example: p2 is not poisonous, no matter what (hint 2). p3 is in three of the hints. So, maybe reasoning about p3 is a good idea. p3 (like any boolean variable) is either True or False. Suppose p3 is True. Then, by Hint 4, we know that p4 is not poisonous. And so on ... Suppose p3 is False. Then, by hint 3, p1 is poisonous. And so on... Keep reasoning until you find a correct solution (even better - find two of them!). Do this until you are comfortable with what is going on with the code!