def part1_and_2(lines, draw_diagonal=False):
    """
    Part1: Consider only horizontal and vertical lines.
    Part2: Consider horizontal, vertical, *and* diagonal lines.
           All diagonal lines will be exactly 45 degrees

    At how many points do at least two lines overlap?
    """
    # create the empty graph
    graph = dict()
    for y in range(0,1000):
        graph[y] = [0 for x in range(1000)]

    # draw lines:
    for line in lines:
        x1, y1, x2, y2 = line[0], line[1], line[2], line[3]
 
        # vertical line:
        if x1 == x2:
            for i in range(min(y1, y2), max(y1, y2)+1):
                graph[i][x1] += 1

        # horizontal line:
        elif y1 == y2:
            for i in range(min(x1, x2), max(x1, x2)+1):
                graph[y1][i] += 1

        # everything else must be a diagonal line:
        elif draw_diagonal:
            if x1 > x2:
                # ensure x increases from x1 to x2
                x1, y1, x2, y2 = line[2], line[3], line[0], line[1]

            while x1 <= x2:
                graph[y1][x1] += 1

                x1 += 1
                if y1 < y2: # downhill slope
                    y1 += 1
                else: # uphill slope
                    y1 -= 1

    # count the number of crossing lines
    crossing_lines = 0
    for y in graph:
        for spot in graph[y]:
            if spot > 1:
                crossing_lines += 1
 
    return crossing_lines