Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s1 = "Первая строка"
- s2 = "строка"
- # Вариант через строки
- def magic(s1,s2):
- for i in s2:
- if not (i in s1 and s2.count(i)<=s1.count(i)):
- return False
- return True
- #Вариант через словари
- def magic2(s1,s2):
- m1 = {i:s1.count(i) for i in set(s1)}
- m2 = {i:s2.count(i) for i in set(s2)}
- for i in m2.keys():
- if not (i in m1.keys() and m2[i]<=m1[i]):
- return False
- return True
- magic(s1,s2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement