Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def have_adjacent_same(a):
- for i in range(len(a) - 1):
- if a[i] == a[i + 1]:
- return True
- return False
- from itertools import product
- alphabet, n = [i for i in input()], int(input())
- words, c = [i for i in product(alphabet, repeat=n) if have_adjacent_same(i)], 0
- for i in words:
- for j in i:
- print(j, end="")
- c += 1
- print()
- print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement