You are viewing a single comment's thread. Return to all comments →
from itertools import combinations def alternate(s): seen = set() for c in s: if c not in seen: seen.add(c) res = 0 for comb in combinations(seen, r=2): s_ = ''.join([c for c in s if c in comb]) cond = True for i in range(len(s_)-1): if s_[i] == s_[i+1]: cond = False break if cond: res = max(res, len(s_)) return res
Seems like cookies are disabled on this browser, please enable them to open this website
Two Characters
You are viewing a single comment's thread. Return to all comments →