renaming for sorting issue

This commit is contained in:
Yann Esposito (Yogsototh) 2017-12-11 15:59:07 +01:00
parent 6ee22fa9cc
commit 31a1dceadd
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
13 changed files with 113 additions and 113 deletions

View file

@ -28,15 +28,15 @@ library
hs-source-dirs: hs-source-dirs:
src src
exposed-modules: exposed-modules:
Day1 Day01
Day2 Day02
Day3 Day03
Day4 Day04
Day5 Day05
Day6 Day06
Day7 Day07
Day8 Day08
Day9 Day09
Day10 Day10
other-modules: other-modules:
Paths_adventofcode Paths_adventofcode

View file

@ -8,13 +8,13 @@ import Text.PrettyPrint hiding ((<>))
import System.Environment (getArgs) import System.Environment (getArgs)
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Day1 import qualified Day01
import qualified Day2 import qualified Day02
import qualified Day5 import qualified Day05
import qualified Day6 import qualified Day06
import qualified Day7 import qualified Day07
import qualified Day8 import qualified Day08
import qualified Day9 import qualified Day09
import qualified Day10 import qualified Day10
showSol :: [Char] -> Doc -> IO () showSol :: [Char] -> Doc -> IO ()
@ -29,73 +29,73 @@ main = do
(Map.lookup args solutions) (Map.lookup args solutions)
solutions :: Map [[Char]] (IO ()) solutions :: Map [[Char]] (IO ())
solutions = Map.fromList [(["1"], day1) solutions = Map.fromList [(["01"], day01)
,(["2"], day2) ,(["02"], day02)
,(["5"], day5) ,(["05"], day05)
,(["6"], day6) ,(["06"], day06)
,(["7"], day7) ,(["07"], day07)
,(["8"], day8) ,(["08"], day08)
,(["9"], day9) ,(["09"], day09)
,(["10"], day10) ,(["10"], day10)
] ]
day1 :: IO () day01 :: IO ()
day1 = do day01 = do
putText "Day 1:" putText "Day 01:"
input1 <- Day1.ex1code input1 <- Day01.ex1code
showSol "Solution 1" (int (Day1.solution1 input1)) showSol "Solution 1" (int (Day01.solution1 input1))
showSol "Solution 2" (int (Day1.solution2 input1)) showSol "Solution 2" (int (Day01.solution2 input1))
day2 :: IO () day02 :: IO ()
day2 = do day02 = do
putText "Day 2:" putText "Day 02:"
input <- Day2.parseInput input <- Day02.parseInput
let sol1 = maybe 0 Day2.solution1 input let sol1 = maybe 0 Day02.solution1 input
showSol "Solution 1" (integer sol1) showSol "Solution 1" (integer sol1)
let sol2 = maybe 0 Day2.solution2 input let sol2 = maybe 0 Day02.solution2 input
showSol "Solution 2" (integer sol2) showSol "Solution 2" (integer sol2)
day5 :: IO () day05 :: IO ()
day5 = do day05 = do
putText "Day 5:" putText "Day 05:"
input5 <- Day5.parseInput input5 <- Day05.parseInput
sol5 <- Day5.solution2 input5 sol5 <- Day05.solution2 input5
showSol "Solution 2" (int sol5) showSol "Solution 2" (int sol5)
day6 :: IO () day06 :: IO ()
day6 = do day06 = do
putText "Day 6:" putText "Day 06:"
input6_1 <- Day6.parseInput input6_1 <- Day06.parseInput
sol6_1 <- Day6.solution1 input6_1 sol6_1 <- Day06.solution1 input6_1
showSol "Solution 1" (int sol6_1) showSol "Solution 1" (int sol6_1)
input6_2 <- Day6.parseInput input6_2 <- Day06.parseInput
sol6_2 <- Day6.solution2 input6_2 sol6_2 <- Day06.solution2 input6_2
showSol "Solution 2" (int sol6_2) showSol "Solution 2" (int sol6_2)
day7 :: IO () day07 :: IO ()
day7 = do day07 = do
putText "Day 7:" putText "Day 07:"
input <- Day7.parseInput input <- Day07.parseInput
let sol_1 = Day7.rootOf input let sol_1 = Day07.rootOf input
showSol "Solution 1" (text (toS (maybe "" Day7.name sol_1))) showSol "Solution 1" (text (toS (maybe "" Day07.name sol_1)))
let sol_2 = Day7.solution2 input let sol_2 = Day07.solution2 input
showSol "Solution 2" (int (maybe 0 snd sol_2)) showSol "Solution 2" (int (maybe 0 snd sol_2))
day8 :: IO () day08 :: IO ()
day8 = do day08 = do
putText "Day 8:" putText "Day 08:"
input <- Day8.parseInput input <- Day08.parseInput
let sol1 = Day8.solution1 input let sol1 = Day08.solution1 input
showSol "Solution 1" (int sol1) showSol "Solution 1" (int sol1)
let sol2 = Day8.solution2 input let sol2 = Day08.solution2 input
showSol "Solution 2" (int sol2) showSol "Solution 2" (int sol2)
day9 :: IO () day09 :: IO ()
day9 = do day09 = do
putText "Day 9:" putText "Day 09:"
sol1 <- Day9.solution1 sol1 <- Day09.solution1
showSol "Solution 1" (int sol1) showSol "Solution 1" (int sol1)
sol2 <- Day9.solution2 sol2 <- Day09.solution2
showSol "Solution 2" (int sol2) showSol "Solution 2" (int sol2)
day10 :: IO () day10 :: IO ()

View file

@ -13,15 +13,15 @@ extra-source-files:
library: library:
source-dirs: src source-dirs: src
exposed-modules: exposed-modules:
- Day1 - Day01
- Day2 - Day02
- Day3 - Day03
- Day4 - Day04
- Day5 - Day05
- Day6 - Day06
- Day7 - Day07
- Day8 - Day08
- Day9 - Day09
- Day10 - Day10
dependencies: dependencies:
- base >=4.7 && <5 - base >=4.7 && <5

View file

@ -1,5 +1,5 @@
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
module Day1 where module Day01 where
import Protolude import Protolude

View file

@ -45,7 +45,7 @@ In this example, the sum of the results would be 4 + 3 + 2 = 9.
What is the sum of each row's result in your puzzle input? What is the sum of each row's result in your puzzle input?
|-} |-}
module Day2 where module Day02 where
import Protolude import Protolude
import qualified Control.Foldl as F import qualified Control.Foldl as F

View file

@ -49,7 +49,7 @@ What is the first value written that is larger than your puzzle input?
|-} |-}
module Day3 where module Day03 where
import Protolude import Protolude
import qualified Control.Foldl as F import qualified Control.Foldl as F

View file

@ -34,7 +34,7 @@ oiii ioii iioi iiio is not valid - any of these words can be rearranged to form
Under this new system policy, how many passphrases are valid? Under this new system policy, how many passphrases are valid?
|-} |-}
module Day4 where module Day04 where
import Protolude import Protolude
import qualified Data.Text as Text import qualified Data.Text as Text

View file

@ -52,7 +52,7 @@ offset values after finding the exit are left as 2 3 2 3 -1.
How many steps does it now take to reach the exit? How many steps does it now take to reach the exit?
|-} |-}
module Day5 where module Day05 where
import Protolude import Protolude

View file

@ -59,7 +59,7 @@ How many cycles are in the infinite loop that arises from the configuration in
your puzzle input? your puzzle input?
|-} |-}
module Day6 where module Day06 where
import Protolude import Protolude

View file

@ -104,7 +104,7 @@ to be to balance the entire tower?
|-} |-}
module Day7 where module Day07 where
import Protolude import Protolude

View file

@ -35,7 +35,7 @@ What is the largest value in any register after completing the instructions in
your puzzle input? your puzzle input?
|-} |-}
module Day8 where module Day08 where
import Protolude hiding ((<|>),many) import Protolude hiding ((<|>),many)

View file

@ -82,7 +82,7 @@ characters or the ! doing the canceling.
How many non-canceled characters are within the garbage in your puzzle input? How many non-canceled characters are within the garbage in your puzzle input?
|-} |-}
module Day9 where module Day09 where
import Protolude hiding ((<|>),many) import Protolude hiding ((<|>),many)

View file

@ -4,12 +4,12 @@ import Test.Tasty
import Test.Tasty.HUnit import Test.Tasty.HUnit
import Control.Monad (when) import Control.Monad (when)
import qualified Day1 import qualified Day01
import qualified Day2 import qualified Day02
import qualified Day5 import qualified Day05
import qualified Day6 import qualified Day06
import qualified Day7 import qualified Day07
import qualified Day8 import qualified Day08
import qualified Day10 import qualified Day10
@ -19,67 +19,67 @@ main = defaultMain $
[ [
testGroup "Day 1" testGroup "Day 1"
[ testGroup "solution 1" [ testGroup "solution 1"
[ testCase "1122 is 3" $ Day1.solution1 "1122" @?= 3 [ testCase "1122 is 3" $ Day01.solution1 "1122" @?= 3
, testCase "1111 is 4" $ Day1.solution1 "1111" @?= 4 , testCase "1111 is 4" $ Day01.solution1 "1111" @?= 4
, testCase "1234 is 0" $ Day1.solution1 "1234" @?= 0 , testCase "1234 is 0" $ Day01.solution1 "1234" @?= 0
, testCase "91212129 is 9" $ Day1.solution1 "91212129" @?= 9 , testCase "91212129 is 9" $ Day01.solution1 "91212129" @?= 9
] ]
, testGroup "solution 2" , testGroup "solution 2"
[ testCase "1212 is 6" $ Day1.solution2 "1212" @?= 6 [ testCase "1212 is 6" $ Day01.solution2 "1212" @?= 6
, testCase "1221 is 0" $ Day1.solution2 "1221" @?= 0 , testCase "1221 is 0" $ Day01.solution2 "1221" @?= 0
, testCase "123425 is 0" $ Day1.solution2 "123425" @?= 4 , testCase "123425 is 0" $ Day01.solution2 "123425" @?= 4
, testCase "123123 is 12" $ Day1.solution2 "123123" @?= 12 , testCase "123123 is 12" $ Day01.solution2 "123123" @?= 12
, testCase "12131415 is 4" $ Day1.solution2 "12131415" @?= 4 , testCase "12131415 is 4" $ Day01.solution2 "12131415" @?= 4
] ]
] ]
, testGroup "Day 2" , testGroup "Day 2"
[ testCase "example problem 1" $ [ testCase "example problem 1" $
Day2.solution1 [[5,1,9,5],[7,5,3],[2,4,6,8]] @?= 18 Day02.solution1 [[5,1,9,5],[7,5,3],[2,4,6,8]] @?= 18
, testCase "example problem 2" $ , testCase "example problem 2" $
Day2.solution2 [[5,9,2,8],[9,4,7,3],[3,8,6,5]] @?= 9 Day02.solution2 [[5,9,2,8],[9,4,7,3],[3,8,6,5]] @?= 9
] ]
, testGroup "Day 5" , testGroup "Day 5"
[ testCaseSteps "example problem 1" $ \step -> do [ testCaseSteps "example problem 1" $ \step -> do
step "Loading input" step "Loading input"
input <- Day5.testArray input <- Day05.testArray
step "Running solution 1" step "Running solution 1"
sol1 <- Day5.solution1 input sol1 <- Day05.solution1 input
when (sol1 /= 5) (assertFailure "Should be 5 steps") when (sol1 /= 5) (assertFailure "Should be 5 steps")
, testCaseSteps "example problem 2" $ \step -> do , testCaseSteps "example problem 2" $ \step -> do
step "Loading input" step "Loading input"
input <- Day5.testArray input <- Day05.testArray
step "Running solution 2" step "Running solution 2"
sol2 <- Day5.solution2 input sol2 <- Day05.solution2 input
when (sol2 /= 10) (assertFailure "Day 6 solution 2 on the example should be 4") when (sol2 /= 10) (assertFailure "Day 6 solution 2 on the example should be 4")
] ]
, testGroup "Day 6" , testGroup "Day 6"
[ testCaseSteps "example problem 1" $ \step -> do [ testCaseSteps "example problem 1" $ \step -> do
step "Loading input" step "Loading input"
input <- Day6.testArray input <- Day06.testArray
step "Running solution 1" step "Running solution 1"
sol1 <- Day6.solution1 input sol1 <- Day06.solution1 input
when (sol1 /= 5) (assertFailure "Should be 5 steps") when (sol1 /= 5) (assertFailure "Should be 5 steps")
, testCaseSteps "example problem 2" $ \step -> do , testCaseSteps "example problem 2" $ \step -> do
step "Loading input" step "Loading input"
input <- Day6.testArray input <- Day06.testArray
step "Running solution 2" step "Running solution 2"
sol2 <- Day6.solution2 input sol2 <- Day06.solution2 input
when (sol2 /= 4) (assertFailure "Day 6 solution 2 on the example should be 4") when (sol2 /= 4) (assertFailure "Day 6 solution 2 on the example should be 4")
] ]
, testGroup "Day 7" , testGroup "Day 7"
[ testCaseSteps "example problem 1" $ \step -> do [ testCaseSteps "example problem 1" $ \step -> do
step "Running solution 1" step "Running solution 1"
let input = Day7.testNodes let input = Day07.testNodes
let sol1 = maybe "" Day7.name (Day7.rootOf input) let sol1 = maybe "" Day07.name (Day07.rootOf input)
when (sol1 /= "tknk") (assertFailure "The root should be tknk") when (sol1 /= "tknk") (assertFailure "The root should be tknk")
, testCase "example on solution 2" $ , testCase "example on solution 2" $
maybe 0 snd (Day7.solution2 Day7.testNodes) @?= 60 maybe 0 snd (Day07.solution2 Day07.testNodes) @?= 60
] ]
, testGroup "Day 8" , testGroup "Day 8"
[ testCase "example problem 1" $ [ testCase "example problem 1" $
Day8.solution1 Day8.testInstructions @?= 1 Day08.solution1 Day08.testInstructions @?= 1
, testCase "example problem 1" $ , testCase "example problem 1" $
Day8.solution2 Day8.testInstructions @?= 10 Day08.solution2 Day08.testInstructions @?= 10
] ]
, testGroup "Day 10" , testGroup "Day 10"
[ testCase "example 1" $ [ testCase "example 1" $