October 18th, 2012, 04:04 AM

LOL...I wish making it work was all i needed...hehe, i would have been done long ago,
my teachers mark everything including the quality of docstring...also, they want the summarized codes most of the time which they refer to as 'pythonic', and the closest thing i found on string was isalpha...
October 18th, 2012, 06:15 PM

Okay, so i made the code... Can someone check what is wrong with it??
Code:
def is_match (puzzle,view):
'''(str,str)>bool
returns true iff puzzle and view match in the place
where the letters are hidden
>>>is_match ('apples','^pp^^^')
True
>>>is_match ('applesbananas','^^^^^^^^^^^^^')
False
>>>is_match ('applesi', '^^^^^^^')
True
>>>is_match ('applesi', '^^^^^^^^')
False
>>>is_match ('apples','^pp^a^')
False
'''
a = 0
if len(view) == len(puzzle):
for i in range(len(puzzle)):
if (puzzle[i] != view[i] and view[i] != HIDDEN):
return False
else:
return False
return True
October 18th, 2012, 10:04 PM

Originally Posted by wikipedia
Code:
Binary operations
Truth table for all binary logical operators
Here is a truth table giving definitions of all 16 of the possible truth functions of 2 binary variables (P,Q are thus boolean variables):
P Q 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
T T F F F F F F F F T T T T T T T T
T F F F F F T T T T F F F F T T T T
F T F F T T F F T T F F T T F F T T
F F F T F T F T F T F T F T F T F T
where T = true and F = false.
Key:
Operation name
0 Opq xand false Contradiction
1 Xpq NOR ↓ Logical NOR
2 Mpq Xq Converse nonimplication
3 Fpq Np ¬p Negation
4 Lpq Xp ↛ Material nonimplication
5 Gpq Nq ¬q Negation
6 Jpq XOR ⊕ Exclusive disjunction
7 Dpq NAND ↑ Logical NAND
8 Kpq AND ∧ Logical conjunction
9 Epq XNOR If and only if Logical biconditional
10 Hpq q Projection function
11 Cpq XNp if/then Material implication
12 Ipq p Projection function
13 Bpq XNq then/if Converse implication
14 Apq OR ∨ Logical disjunction
15 Vpq xnand true Tautology
Also consider "not".
[code]
Code tags[/code] are essential for python code and Makefiles!