github.com/cycloss/advent-of-code@v0.0.0-20221210145555-15039b95faa6/2021/day5/day5Strategy.md (about)

     1  # Day 5 Strategy
     2  
     3  ## Parsing
     4  
     5  - For each line of input
     6      - find the smallest x and y values
     7      - create a struct called ventLine with two vector2s start and end
     8      - put the smallest x,y pair in start, and largest in end
     9      - create a bool method diagonal on ventLine that returns true if neither x and y values match
    10  
    11  ## Algorithm
    12  
    13  - Create a hashmap, countMap, of map[vector2]int to count vents at each point
    14  - For each ventLine struct
    15      - If diagonal
    16          - continue
    17      - Else
    18          - Create x and y values with the start vector2s x and y
    19          - While they are less than the end x and y values
    20              - create a vector2, currentCoord, out of x and y
    21              - increment countMap[currentCoord] by 1
    22              - increment x and y by 1
    23  - return count of where there are >= 2 vents at a given key