From a37ce2930d967d7375d4b4769a8d54c0ded79ac7 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 8 Dec 2020 11:04:11 +0100 Subject: [PATCH] WIP 2015 day 9 --- haskellAoC/inputs/2015/09 | 28 ++++++++++++++++++++++++++++ haskellAoC/inputs/2015/09_test | 3 +++ haskellAoC/src/Y2015/Day09.hs | 14 ++++++++++++++ haskellAoC/src/Y2015/Days.hs | 2 ++ 4 files changed, 47 insertions(+) create mode 100644 haskellAoC/inputs/2015/09 create mode 100644 haskellAoC/inputs/2015/09_test create mode 100644 haskellAoC/src/Y2015/Day09.hs diff --git a/haskellAoC/inputs/2015/09 b/haskellAoC/inputs/2015/09 new file mode 100644 index 0000000..997758f --- /dev/null +++ b/haskellAoC/inputs/2015/09 @@ -0,0 +1,28 @@ +Tristram to AlphaCentauri = 34 +Tristram to Snowdin = 100 +Tristram to Tambi = 63 +Tristram to Faerun = 108 +Tristram to Norrath = 111 +Tristram to Straylight = 89 +Tristram to Arbre = 132 +AlphaCentauri to Snowdin = 4 +AlphaCentauri to Tambi = 79 +AlphaCentauri to Faerun = 44 +AlphaCentauri to Norrath = 147 +AlphaCentauri to Straylight = 133 +AlphaCentauri to Arbre = 74 +Snowdin to Tambi = 105 +Snowdin to Faerun = 95 +Snowdin to Norrath = 48 +Snowdin to Straylight = 88 +Snowdin to Arbre = 7 +Tambi to Faerun = 68 +Tambi to Norrath = 134 +Tambi to Straylight = 107 +Tambi to Arbre = 40 +Faerun to Norrath = 11 +Faerun to Straylight = 66 +Faerun to Arbre = 144 +Norrath to Straylight = 115 +Norrath to Arbre = 135 +Straylight to Arbre = 127 diff --git a/haskellAoC/inputs/2015/09_test b/haskellAoC/inputs/2015/09_test new file mode 100644 index 0000000..d8224f9 --- /dev/null +++ b/haskellAoC/inputs/2015/09_test @@ -0,0 +1,3 @@ +London to Dublin = 464 +London to Belfast = 518 +Dublin to Belfast = 141 \ No newline at end of file diff --git a/haskellAoC/src/Y2015/Day09.hs b/haskellAoC/src/Y2015/Day09.hs new file mode 100644 index 0000000..f0a210e --- /dev/null +++ b/haskellAoC/src/Y2015/Day09.hs @@ -0,0 +1,14 @@ +module Y2015.Day09 (y15day09) where + +import Data.List.Split + +parseInput :: String -> (String, String, Int) +parseInput input = (city1, city2, dist) + where (city1:split1:_) = splitOn " to " input + (city2:raw_dist:_) = splitOn " = " split1 + dist = read $ raw_dist + +y15day09 :: [String] -> (String, String) +y15day09 input = (part1, part2) + where part1 = show $ map parseInput input + part2 = "WIP" diff --git a/haskellAoC/src/Y2015/Days.hs b/haskellAoC/src/Y2015/Days.hs index f58daf4..b02db39 100644 --- a/haskellAoC/src/Y2015/Days.hs +++ b/haskellAoC/src/Y2015/Days.hs @@ -8,6 +8,7 @@ import Y2015.Day05 import Y2015.Day06 import Y2015.Day07 import Y2015.Day08 +import Y2015.Day09 year2015 :: String -> [String] -> (String, String) year2015 "01" = y15day01 @@ -18,3 +19,4 @@ year2015 "05" = y15day05 year2015 "06" = y15day06 year2015 "07" = y15day07 year2015 "08" = y15day08 +year2015 "09" = y15day09