[Solved] Finding regular expression with at least one repetition of each letter


You could find all substrings of length 4+, and then down select from those to find only the shortest possible combinations that contain one of each letter:

s="AAGTCCTAG"

def get_shortest(s):
  l, b = len(s), set('ATCG')
  options = [s[i:j+1] for i in range(l) for j in range(i,l) if (j+1)-i > 3]
  return [i for i in options if len(set(i) & b) == 4 and (set(i) != set(i[:-1]))]

print(get_shortest(s))

Output:

['AAGTC', 'AGTC', 'GTCCTA', 'TCCTAG', 'CCTAG', 'CTAG']

solved Finding regular expression with at least one repetition of each letter