def cant_put_boat(b, x, y, dir, grid):
    # you don't need to test every position
    return dir == HORIZ and x + b >= 10
        or dir == VERT and y + b >= 10
def put_boat(b, x, y, dir, grid):
    if dir == HORIZ:
        for i in range(b):
            position = x + 10*y
            grid.append[position]
            position = position + 1
    if dir == VERT:
        for k in range(b):
            position = x + 10*y
            grid.append[position]
            position = position + 10 
def play(grid):
    x, y = random
    while cant_shoot(grid, x, y)
        x, y = random
    shoot(x, y)
def can_shoot(grid, shot):
    prev_shoots = []
    for j in range(len(prev_shoots)):
        if shot == prev_shoots[j]:
            return False
    return True
def shoot(grid, shot):
    grid.pop(shot)
    grid.insert(shot, 'X')
