
October 18th, 2012, 05:15 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Posts: 44
Time spent in forums: 11 h 46 m 55 sec
Reputation Power: 1
|
|
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 ('apples-bananas','^^^^^^^^^^^^^')
False
>>>is_match ('apples-i', '^^^^^^-^')
True
>>>is_match ('apples-i', '^^^^^^^^')
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
|