Advertisement
dmemsm

Задача 10

Jan 12th, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. # Немножко со строками, но работает же!)
  2. from collections import Counter
  3.  
  4. n1 = input()
  5. n2 = input()
  6.  
  7. n1_counts = Counter(n1)
  8. n2_counts = Counter(n2)
  9.  
  10. result = True
  11. for k, v in n2_counts.items():
  12.     if k not in n1_counts.keys():
  13.         result = False
  14.         break
  15.     if v > n1_counts[k]:
  16.         result = False
  17.         break
  18.  
  19.  
  20. print(f"Из {n1} {'можно' if result else 'нельзя'} составить {n2}")
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement