From cfbc0230f93a6a0e53255d220dca78208c7b7eb9 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sat, 3 Dec 2016 20:47:17 +0000 Subject: [PATCH] Tweaks --- advent03.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/advent03.hs b/advent03.hs index 3a6357d..a9a2353 100644 --- a/advent03.hs +++ b/advent03.hs @@ -23,7 +23,9 @@ part2 triangles = do parseLine :: String -> Triple parseLine = map (read) . filter (not . null) . splitOn " " +validTriangle :: Triple -> Bool validTriangle triple = sortedTriple!!0 + sortedTriple!!1 > sortedTriple!!2 where sortedTriple = sort triple -byColumns triangles = chunksOf 3 $ concat $ transpose triangles +byColumns :: [[Integer]] -> [Triple] +byColumns = chunksOf 3 . concat . transpose -- 2.34.1