Ejemplo n.º 1
0
 def test_is_merge_iterative(self):
     self.assertTrue(is_merge_iterative("codewars", "cdw", "oears"))
Ejemplo n.º 2
0
 def test_is_merge_iterative(self):
     self.assertTrue(is_merge_iterative("codewars", "cdw", "oears"))
Ejemplo n.º 3
0
"""
At a job interview, you are challenged to write an algorithm to check if a
given string, s, can be formed from two other strings, part1 and part2.
The restriction is that the characters in part1 and part2 are in the same
order as in s. The interviewer gives you the following example and tells
you to figure out the rest from the given test cases.
'codewars' is a merge from 'cdw' and 'oears':
s:  c o d e w a r s   = codewars
part1:  c   d   w         = cdw
part2:    o   e   a r s   = oears
"""

from algorithms.strings import is_merge_recursive, is_merge_iterative

s = "codewars"
part1 = "cdw"
part2 = "oears"

print(is_merge_recursive(s, part1, part2))

print(is_merge_iterative(s, part1, part2))