Created
March 12, 2016 04:30
-
-
Save deanproxy/4e033882d49494b994ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_word_in_puzzle(word, puzzle): | |
count = 0 | |
for i in (puzzle + zip(*puzzle)): | |
w = ''.join(i) | |
if word in w or word in w[::-1]: | |
count += 1 | |
return count | |
puzzle = [ | |
['h', 'e', 'l', 'l', 'o'], | |
['e', 'r', 'f', 'j', 'g'], | |
['l', 'g', 'h', 'j', 'j'], | |
['l', 'u', 'c', 'k', 'y'], | |
['o', 'l', 'l', 'e', 'h'] | |
] | |
print count_word_in_puzzle('hello', puzzle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment