<commit_before>import Data.List (transpose)
import Data.List.Split (splitOn, chunksOf)

main :: IO ()
main = do
  content <- readFile "problem011.txt"
  let l = [ read x :: Int | x <- foldl (++) [] $ map (splitOn " ") (lines content)]
  let rows = getRows l
  let cols = getColums rows
  let maxRows = maximum $ map (maxAdjacent 0) rows
  let maxCols = maximum $ map (maxAdjacent 0) cols
  putStrLn ("maxCols: " ++ show maxCols)
  putStrLn ("maxRows: " ++ show maxRows)

-- NW - SE => [ l !! (20 * x + x) | x <- [0..19]]
-- [ [ l !! ((y+x) * 20 + x) | x <- [0..19-y]] | y <- [16,15..0] ]
-- [ [ l !! ((y+x) + 20 * x) | x <- [0..19-y]] | y <- [1..16] ]
--
-- NE - SW => [ l !! (19 * x) | x <- [1..20]]
--
getNWSE :: [Int] -> [[Int]]
getNWSE xs = [
  [ xs !! i | x <- [0..19 - abs y], let i = getIndex x y ] | y <- [16,15..(-16)] ]
    where getIndex a b = if (b < 0) then ((abs b + a) + 20 * a) else ((abs b + a) * 20 + a)

getColums :: [[Int]] -> [[Int]]
getColums xs = transpose xs

maxAdjacent :: Int -> [Int] -> Int<commit_msg>problem 11 completed<commit_after>import Data.List (transpose)
import Data.List.Split (splitOn, chunksOf)

main :: IO ()
main = do
  content <- readFile "problem011.txt"
  let l = [ read x :: Int | x <- foldl (++) [] $ map (splitOn " ") (lines content)]
  let rows = getRows l
  let cols = getColums rows
  let nesw = getNESW l
  let nwse = getNWSE l
  let maxRows = maximum $ map (maxAdjacent 0) rows
  let maxCols = maximum $ map (maxAdjacent 0) cols
  let maxNESW = maximum $ map (maxAdjacent 0) nesw
  let maxNWSE = maximum $ map (maxAdjacent 0) nwse
  putStrLn ("maxCols: " ++ show maxCols)
  putStrLn ("maxRows: " ++ show maxRows)
  putStrLn ("maxNESW: " ++ show maxNESW)
  putStrLn ("maxNWSE: " ++ show maxNWSE)

getNESW :: [Int] -> [[Int]]
getNESW xs = [
  [ xs !! i |  x <- [start y..abs y], let i = getIndex x y ] | y <- [3..19] ++ [(-19)..(-4)] ]
    where getIndex a b = if (b < 0) then (20 * (20 + b) + (19 * a)) else (b + 19 * a)
          start x = if (x < 0) then 1 else 0

getNWSE :: [Int] -> [[Int]]
getNWSE xs = [
  [ xs !! i | x <- [0..19 - abs y], let i = getIndex x y ] | y <- [16,15..(-16)] ]
    where getIndex a b = if (b < 0) then ((abs b + a) + 20 * a) else ((abs b + a) * 20 + a)

getColums :: [[Int]] -> [[Int]]
getColums xs = transpose xs

maxAdjacent :: Int -> [Int] -> Int
{'fraction_non_alphanumeric': 0.20608397600685519, 'fraction_numerical': 0.037703513281919454, 'mean_word_length': 2.564885496183206, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1944739', 'n_tokens_mistral': 1036, 'n_tokens_neox': 943, 'n_words': 313}