Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- def calculate(k, phrase, text):
- result = []
- for start in range(len(text)):
- to_compare = ''
- for phrase_index in range(len(phrase)):
- if start + phrase_index * k < len(text):
- to_compare += text[start + phrase_index * k]
- print str(start) + ' ' + phrase + '!=' + to_compare
- if phrase == to_compare:
- result.append({'start': start, 'k' : k, 'phrase': phrase})
- return result
- text = u'zbadawszyplikeksperciorzekli'
- phrase = u'pies'
- result = calculate(k=2, phrase=phrase, text=text)
- print result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement