anchor.diff:  ﻿module _2021_5
   
   open System
  -open System.Linq
  -open System.Diagnostics
   
   // Task 1: Find number of points were a horizontal/vertical line overlaps
  -// Task 2: 
  +// Task 2: Include diagonal lines in calc
   type Point = 
       struct 
           val X: int
  
positive.code:                                             Seq.head)
      (x, y)
  
  let isHorizontal (line:Point[]) = line[0].Y = line[1].Y
  let isVertical (line:Point[]) = line[0].X = line[1].X
  let minX (line:Point[]) = min line[0].X line[1].X
  let minY (line:Point[]) = min line[0].Y line[1].Y
  let maxX (line:Point[]) = max line[0].X line[1].X
  let maxY (line:Point[]) = max line[0].Y line[1].Y
  
  let minByX (line:Point[]) = Array.minBy (fun (x:Point) -> x.X)
  let maxByX (line:Point[]) = Array.minBy (fun (x:Point) -> x.X)
  let minByY (line:Point[]) = Array.minBy (fun (x:Point) -> x.Y)
  let maxByY (line:Point[]) = Array.minBy (fun (x:Point) -> x.Y)
  
  // 1. I originally wanted to do a recursive function that checked every line against every other line
  //    which was super inefficient. It didn't give me the correct result, so instead of debugging it 
  
negative.code:         | _ -> addPoints ((List.tail points), (map.Change((List.head points), increment)))
  
      let generatePoints line =
          let generateDiagonal line = 
              let start:Point = minByX line
              let stop:Point = maxByX line
          
              if start.Y < stop.Y then
                  [ for i in 0 .. (stop.X - start.X) -> new Point(start.X + i, start.Y + i) ]
              else 
                  [ for i in 0 .. (stop.X - start.X) -> new Point(start.X + i, start.Y - i) ]
  
          match line with 
          | x when isHorizontal x || isVertical x -> 
              [ for x in (minX line) .. (maxX line) do 
                  for y in (minY line) .. (maxY line) -> new Point(x,y)]
          | _ -> generateDiagonal line
  
      let result = addPoints ((generatePoints line), map)
  
  