```
puzzle = [list(line) for line in puzzle.split()]
xs = list(range(len(puzzle[0])))
ys = list(range(len(puzzle)))
table = dict(((x,y),puzzle[y][x]) for x,y in product(xs,ys))
ships = dict((str(i),s) for i,s in enumerate(ships.split()))
in_bounds = set(product(xs,ys))
symbols = '. ~ O # < > v ^'.split()
maybe_int = lambda s: '?' if s is '?' else int(s)
across = [maybe_int(n) for n in across.split()]
down = [maybe_int(n) for n in down.split()]
if '?' not in across:
assert sum(across) == sum(len(s) for s in ships.values())
if '?' not in down:
assert sum(down) == sum(len(s) for s in ships.values())
```