2021/05.py
def part1(lines: List[str]) -> int:
    """
    For part 1, you only have to consider horizontal and vertical lines. That is, lines
    where either x1 = x2 or y1 = y2.
    """
    G = defaultdict(int)
    for (x1, y1), (x2, y2) in parselines(lines):
        if x1 != x2 and y1 != y2:
            # This technique works for part 1 because x1 = x2 or y1 = y2 so sorting will
            # actually do what we want (which is to put the one that is smaller first,
            # making the range based for loop work better later).
            continue

        for x, y in int_points_between((x1, y1), (x2, y2)):
            G[(x, y)] += 1

    return sum([1 for x in G.values() if x > 1])

    For part 1, you only have to consider horizontal and vertical lines. That is, lines
    where either x1 = x2 or y1 = y2.
    
For part 1, you only have to consider horizontal and vertical lines. That is, lines
where either x1 = x2 or y1 = y2.
For part 1 you only have to consider horizontal and vertical lines . That is lines where either x1 = x2 or y1 = y2 .
def part1(lines: List[str]) -> int:
    G = defaultdict(int)
    for (x1, y1), (x2, y2) in parselines(lines):
        if x1 != x2 and y1 != y2:
            continue
        for x, y in int_points_between((x1, y1), (x2, y2)):
            G[(x, y)] += 1
    return sum([1 for x in G.values() if x > 1])
def part1 ( lines : List [ str ] ) -> int : G = defaultdict ( int ) for ( x1 , y1 ) , ( x2 , y2 ) in parselines ( lines ) : if x1 != x2 and y1 != y2 : continue for x , y in int_points_between ( ( x1 , y1 ) , ( x2 , y2 ) ) : G [ ( x , y ) ] += 1 return sum ( [ 1 for x in G . values ( ) if x > 1 ] )
For part 1, you only have to consider horizontal and vertical lines.
For part 1 you only have to consider horizontal and vertical lines .
"""
    For part 1, you only have to consider horizontal and vertical lines. That is, lines
    where either x1 = x2 or y1 = y2.
    """ # This technique works for part 1 because x1 = x2 or y1 = y2 so sorting will # actually do what we want (which is to put the one that is smaller first, # making the range based for loop work better later).
lines
List[str]