# L-9 MCS 275 Mon 4 Feb 2008 : enumwstop
#
# enumerates all combinations of letters
# with interactive stop condition

def ask_to_continue(s):
   """
   shows the string s and then asks
   the user to continue or not
   """
   w = 'the word is \"' + s + '\"'
   w = w + ' continue ? (y/n) '
   ans = raw_input(w)
   if ans == 'y':
      return True
   else:
      return False

def enumwords(k,L,s):
   """
   starting with the k-th list in L,
   adds letters to the current string s,
   returns a boolean: to continue or not
   """
   if k >= len(L):
      return ask_to_continue(s)
   else:
      for i in range(0,len(L[k])):
         c = enumwords(k+1,L,s+L[k][i])
         if not c: break
      return c

def main():
   """
   enumerates letter combinations
   """
   S = ['c','s','v']
   V = ['a','e','i','o','u']
   E = ['d','t','w']
   L = [S,V,E]
   a = enumwords(0,L,"")

main()
