def make_compact(creation_sequence):
 first = creation_sequence[0]
 if isinstance(first, str):
  cs = creation_sequence[:]
 elif isinstance(first, tuple):
  cs = [s[1] for s in creation_sequence]
 elif isinstance(first, int):
  return creation_sequence
 else:
  raise TypeError('Not a valid creation sequence type')
 ccs = []
 count = 1
 for i in range(1, len(cs)):
  if (cs[i] == cs[(i - 1)]):
   count += 1
  else:
   ccs.append(count)
   count = 1
 ccs.append(count)
 return ccs

def make_compact ( creation_sequence ) : first = creation_sequence [ 0 ] if isinstance ( first , str ) : cs = creation_sequence [ : ] elif isinstance ( first , tuple ) : cs = [ s [ 1 ] for s in creation_sequence ] elif isinstance ( first , int ) : return creation_sequence else : raise TypeError ( 'Not a valid creation sequence type' ) ccs = [ ] count = 1 for i in range ( 1 , len ( cs ) ) : if ( cs [ i ] == cs [ ( i - 1 ) ] ) : count += 1 else : ccs . append ( count ) count = 1 ccs . append ( count ) return ccs
returns the creation sequence in a compact form that is the number of is and ds alternating .