Skip to content

Instantly share code, notes, and snippets.

@deanproxy
Created March 12, 2016 04:30
Show Gist options
  • Save deanproxy/4e033882d49494b994ea to your computer and use it in GitHub Desktop.
Save deanproxy/4e033882d49494b994ea to your computer and use it in GitHub Desktop.
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