aboutsummaryrefslogtreecommitdiff
path: root/challenge-082/walt-mankowski/python/ch-2.py
blob: ca2a2d551d32e0720437aa85f5aa1ffda59b870d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from sys import argv

def is_interleave(a, b, c):
    if a == '' and b == '' and c == '':
        return 1

    try:
        if a[0] == c[0]:
            return is_interleave(a[1:], b, c[1:])
    except IndexError:
        pass

    try:
        if b[0] == c[0]:
            return is_interleave(a, b[1:], c[1:])
    except IndexError:
        pass

    return 0

a, b, c = argv[1:]

print(is_interleave(a, b, c))