Esempio n. 1
0
def check_dragon(image: Image, x: int, y: int):
    for i in range(len(DRAGON)):
        for j in range(len(DRAGON[i])):
            if not image.in_bounds(x + i, y + j):
                return False
            if DRAGON[i][j] == "#" and image.get(x+i, y+j) != "#":
                return False
    return True
Esempio n. 2
0
def fill_dragons(image: Image, indices):
    image = image.copy()
    for x, y in indices:
        for i in range(len(DRAGON)):
            for j in range(len(DRAGON[i])):
                if not image.in_bounds(x + i, y + j):
                    print(f"error: x={x}, y={y}, i: {i}, j: {j}")
                    raise Exception("Unexpected out of bounds while filling")
                if DRAGON[i][j] == "#":
                    if image.get(x + i, y + j) not in ("#", "O"):
                        print(f"error: x={x}, y={y}, i: {i}, j: {j}")
                        raise Exception("Unexpected mismatch while filling")
                    image.put(x+i, y+j, "O")
    return image