Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Monkey Typing by matox
def count_words(text, words):
n = 0
for word in words:
if word in text.lower():
n += 1
return n
if __name__ == '__main__':
#These uu"1sserts" using only for self-checking and not necessary for auto-testing
assert count_words(u"How aresjfhdskfhskd you?", {u"how", u"are", u"you", u"hello"}) == 3, "Example"
assert count_words(u"Bananas, give me bananas!!!", {u"banana", u"bananas"}) == 2, "BANANAS!"
assert count_words(u"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
{u"sum", u"hamlet", u"infinity", u"anything"}) == 1, "Weird text"
Aug. 14, 2014
Comments: