Advertisement
namemkazaza

AA

Dec 8th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. from itertools import product
  2. def have_adjacent_same(a):
  3.     vowels = ['A', 'E', 'I', 'O', 'U']
  4.     for i in range(len(a) - 1):
  5.         if a[i] in vowels and a[i + 1] in vowels:
  6.             return False
  7.     return True
  8. alphabet, n = [i for i in input()], int(input())
  9. words, c = [i for i in product(alphabet, repeat=n) if have_adjacent_same(i)], 0
  10. for i in words:
  11.     for j in i:
  12.         print(j, end="")
  13.     c += 1
  14.     print()
  15. print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement