diff options
Diffstat (limited to 'challenge-256/packy-anderson/python/ch-2.py')
| -rwxr-xr-x | challenge-256/packy-anderson/python/ch-2.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-256/packy-anderson/python/ch-2.py b/challenge-256/packy-anderson/python/ch-2.py new file mode 100755 index 0000000000..a178ffab9e --- /dev/null +++ b/challenge-256/packy-anderson/python/ch-2.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +def mergeStrings(str1, str2): + chars1 = list(str1) + chars2 = list(str2) + result = '' + while chars1 or chars2: + if chars1: + result += chars1.pop(0) + if chars2: + result += chars2.pop(0) + return result + +def solution(str1, str2): + print(f'Input: $str1 = "{str1}", $str2 = "{str2}"') + output = mergeStrings(str1, str2) + print(f'Output: {output}') + +print('Example 1:') +solution("abcd", "1234") + +print('\nExample 2:') +solution("abc", "12345")
\ No newline at end of file |
