def _has_double_couples(s): couples = util.slide(2, s) couple_groups = [ list(value) for key, value in itertools.groupby( sorted( enumerate(couples), key=lambda (_, letters): letters ), key=lambda (_, letters): letters ) ]
def _has_double_letters_with_middle(s): return any([True for a, _, c in util.slide(3, s) if a == c])
def _has_double_letters(s): return any((True for a, b in util.slide(2, s) if a == b))