From: Neil Smith Date: Sat, 3 Dec 2016 20:47:17 +0000 (+0000) Subject: Tweaks X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=cfbc0230f93a6a0e53255d220dca78208c7b7eb9;p=advent-of-code-16.git Tweaks --- 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