diff options
Diffstat (limited to 'challenge-082/walt-mankowski/python/ch-2.py')
| -rw-r--r-- | challenge-082/walt-mankowski/python/ch-2.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/challenge-082/walt-mankowski/python/ch-2.py b/challenge-082/walt-mankowski/python/ch-2.py index 662f0816d6..c9ef4de6f2 100644 --- a/challenge-082/walt-mankowski/python/ch-2.py +++ b/challenge-082/walt-mankowski/python/ch-2.py @@ -3,17 +3,21 @@ from sys import argv def is_interleave(a, b, c): if a == '' and b == '' and c == '': return 1 - elif c == '': - return 0 found = False - if len(a) > 0 and a[0] == c[0]: - found = True - return is_interleave(a[1:], b, c[1:]) + try: + if a[0] == c[0]: + found = True + return is_interleave(a[1:], b, c[1:]) + except IndexError: + pass - if len(b) > 0 and b[0] == c[0]: - found = True - return is_interleave(a, b[1:], c[1:]) + try: + if b[0] == c[0]: + found = True + return is_interleave(a, b[1:], c[1:]) + except IndexError: + pass if not found: return 0 |
