def solution(s: str, part1: str, part2: str)-> bool:
# your code here
li_part1 = list(part1)
li_part2 = list(part2)
if len(s) != len(part1+part2):
return False
else:
for i in s:
if len(li_part1)>0 and i == li_part1[0]:
li_part1.pop(0)
elif len(li_part2)>0 and i == li_part2[0]:
li_part2.pop(0)
else:
return False
return True
assert solution('hogwarts','hws','ogart') is True
assert solution('codewars', 'code', 'wars') is True
assert solution('codewars', 'cod', 'wars') is False
assert solution('codewars', 'code', 'warsl') is False
def solution(s: str, part1: str, part2: str)-> bool:
# your code here
if len(part1) + len(part2) != len(s):
return False
for data in s:
if data in part1:
part1 = part1[part1.index(data)+1:]
print(f"match part1:{data},part1 left:{part1}")
continue
if data in part2:
part2 = part2[part2.index(data)+1:]
print(f"match part2:{data},part2 left:{part2}")
continue
return False
return True
assert solution('hogwarts','hws','ogart') is True
assert solution('codewars', 'code', 'wars') is True
assert solution('codewars', 'cod', 'wars') is False
assert solution('ababab', 'bab', 'aba') is True
assert solution('haah', 'ha', 'ha') is False
def solution(s: str, part1: str, part2: str)-> bool:
res_list=[]
for i in range(len(s)):
if s[i] in part1 or s[i] in part2:
res_list.append(s[i])
for j in range(1,len(part1)):
if s.index(part1[j])<s.index(part1[j-1]):
return False
for k in range(1,len(part2)):
if s.index(part2[k])<s.index(part2[k-1]):
return False
str_res=''.join(res_list)
if str_res==s:
return True
else:
return False
assert solution('hogwarts','hws','ogart') is True
assert solution('codewars', 'code', 'wars') is True
assert solution('codewars', 'cod', 'wars') is False
assert solution('codewars', 'cdoe', 'wars') is False