dxnge

10

Oct 13th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from itertools import product
  2. a = list(map(''.join, product('ABCX', repeat=5)))
  3.  
  4. #   Первый способ
  5. words = []
  6. for i in a:
  7.     if i.count('X') == 1 and i[-1] == 'X' or i.count('X') == 0:
  8.         words.append(i)
  9. print(len(words))
  10.  
  11. # Второй способ
  12. print(len(list(filter(lambda x: x.count('X') == 1 and x[-1] == 'X' or x.count('X') == 0, a))))
Advertisement
Add Comment
Please, Sign In to add comment