""" name: Nicholas Tamassia Honor Code and Acknowledgments: This work complies with the JMU Honor Code. Comments here on your code and submission. """ import pprint def valid_shuffle(a: str, b: str, c: str) -> bool: memo: list[list[bool | None]] = [ ([None] * (len(a) + 1)) for _ in range(0, len(b) + 1) ] memo[len(a)][len(b)] = True def recurse(i: int, j: int) -> bool: if i >= len(a) or j >= len(b): return False k: int = i + j if k == (len(c) - 2): return True a_val: bool | None = memo[i + 1][j] if a_val is None: a_val = recurse(i + 1, j) if a[i] == c[k] else False memo[i + 1][j] = a_val b_val: bool | None = memo[i][j + 1] if b_val is None: b_val = recurse(i, j + 1) if b[j] == c[k] else False memo[i][j + 1] = b_val memo[i][j] = a_val or b_val return a_val or b_val val = recurse(0, 0) pprint.pprint(memo) return val # All modules for CS 412 must include a main method that allows it # to imported and invoked from other python scripts def main(): a: str = input() b: str = input() c: str = input() print(valid_shuffle(a, b, c)) if __name__ == "__main__": main()