Battleship

Solving Battleships with SAT

Comments are moderated. It may take a few minutes before your comment appears.
Markdown is supported in your comments.

def just_ship(prefix, x1, y1, size, d, cache={}):
    "prefix is ignored"
    if (x1, y1, size, d) in cache:
        return cache[(x1, y1, size, d)]
    if d == 'E':
        points = [(x1+i,y1) for i in range(size)]
    elif d == 'S':
        points = [(x1,y1+i) for i in range(size)]
    else:
        raise
    cache[(x1, y1, size, d)] = points
    return points
Name:
Mail: (not shown)

Please type this: