module Snippets where

import Control.Lens
import Data.List
import Linear.V2

p :: Int -> [Int] -> String
p n (x:xs) =
  if n == x
    then '#' : p (n + 1) xs
    else '.' : p (n + 1) (x : xs)
p _ [] = []

print2D :: Int -> [V2 Int] -> [String]
print2D n coords
  | n == pred minY = []
  | otherwise = p minX line : print2D (n - 1) coords
  where
    line = nub $ sort $ map (^. _x) (filter (\(V2 _ a) -> a == n) coords)
    minY = minimum $ map (^. _y) coords
    minX = minimum $ map (^. _x) coords
