def scramble(s1: str, s2: str):
s1 = list(s1)
s2 = list(s2)
s1_dict = Counter(s1)
s2_dict = Counter(s2)
for i in s2:
if i not in s1:
return False
if s2_dict[i] > s1_dict[i]:
return False
return True
def scramble(s1: str, s2: str):
i = 0
temp = list(s1)
while i < len(s2):
if s2[i] in temp:
index = temp.index(s2[i])
temp.pop(index)
i += 1
else:
return False
return True
def scramble(s1: str, s2: str):
l1 = list(s1)
l2 = list(s2)
for i in l1:
if i in l2:
l2.remove(i)
return l2 == []
assert scramble('saetvhwologr', 'hogwarts') is True
assert scramble('rkqodlw', 'world') is True
assert scramble('katas', 'steak') is False
assert scramble('rkqodlw', 'wood') is False
from collections import Counter
def scramble(s1: str, s2: str):
a1 = Counter(s1)
a2 = Counter(s2)
return False if [False if a2[i] > a1[i] else False for i in a2 if i not in a1] else True
assert scramble('saetvhwologr', 'hogwarts') is True
assert scramble('rkqodlw', 'world') is True
assert scramble('katas', 'steak') is False
def scramble(s1: str, s2: str):
for s in set(s2):
if s not in s1 or s1.count(s) < s2.count(s):
return False
return True
assert scramble('saetvhwologr', 'hogwarts') is True
assert scramble('rkqodlw', 'world') is True
assert scramble('katas', 'steak') is False
assert scramble('rkqodlw','wood') is False
def scramble(s1: str, s2: str):
s=0
s1_list=[a for a in s1]
for i in range(len(s2)):
if s2[i] in s1_list:
s1_list.pop(s1_list.index(s2[i]))
s+=1
continue
if s == len(s2):
return True
else:
return False
assert scramble('saetvhwologr', 'hogwarts') is True
assert scramble('rkqodlw', 'world') is True
assert scramble('katas', 'steak') is False