Skip to content

Instantly share code, notes, and snippets.

@avances123
Last active August 29, 2015 14:02
Show Gist options
  • Save avances123/3fb6c343663d59b7f4c4 to your computer and use it in GitHub Desktop.
Save avances123/3fb6c343663d59b7f4c4 to your computer and use it in GitHub Desktop.
ejercicios marcos python
# http://stackoverflow.com/a/19618657/472866
#import ipdb
groups = []
cur_longest = ''
prev_char = ''
##ipdb.set_trace()
for char in s.lower():
if prev_char and char < prev_char:
groups.append(cur_longest)
cur_longest = char
else:
cur_longest += char
prev_char = char
groups.append(cur_longest)
if not groups:
groups = [s]
#print groups
print "Longest substring in alphabetical order is: %s" % max(groups, key=len)
# http://stackoverflow.com/questions/19302525/python-how-to-count-overlapping-occurrences-of-a-substring
import re
veces = len(re.findall('(?=bob)', s))
print "Number of times bob occurs is: %s" % veces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment