import re


def parse_life_105(file):
    """Parse a Life 1.05 file,  returning a tuple:
        positions: list of (x,y) co-ordinates
        comments: all comments in file, as a list of strings, one per line.
    """
    lines = file.split("\n")
    comments = []
    positions = []
    ox, oy = 0, 0
    x, y = ox, oy

    pattern_105 = r"\s*(\.|\*|o|O)+\s*\Z"
    for line in lines:
        line = line.strip().rstrip()

        if line.startswith("#"):
            # comment
            if line[1] in "CcDd":
                comments.append(line[2:])
            # new block definition
            if line[1] in "Pp":
                coords = line[2:]
                try:
                    ox, oy = [int(p) for p in coords.split()]
                    x, y = ox, oy
                except:
                    pass
        else:
            # skip blanks
            if len(line) > 0 and re.match(pattern_105, line):
                # only fill in points which are active
                for char in line:
                    if char == "*" or char == "o" or char == "O":
                        positions.append((x, y))
                    x += 1
                y = y + 1
                x = ox
    comments = "\n".join(comments)

    return positions, comments