trunk
HeNine 2 years ago
parent c3d62c3c5e
commit 7058b3ffd2

@ -18,7 +18,8 @@ test-suite day01aoctest
type: exitcode-stdio-1.0
hs-source-dirs: src/day01/test, src/day01
main-is: AoCTest.hs
other-modules: Day1Lib
other-modules:
Day1Lib
build-depends: base
, HUnit
, split
@ -65,7 +66,8 @@ test-suite day02aoctest
type: exitcode-stdio-1.0
hs-source-dirs: src/day02/test, src/day02
main-is: AoCTest.hs
other-modules: Day2Lib
other-modules:
Day2Lib
build-depends: base
, HUnit
ghc-options: -threaded -rtsopts -with-rtsopts=-N
@ -103,4 +105,30 @@ executable day022
-Wmissing-export-lists
-Wmissing-home-modules
-Wpartial-fields
-Wredundant-constraints
-Wredundant-constraints
-- Day 3
test-suite day03basictest
type: exitcode-stdio-1.0
hs-source-dirs: src/day03/test, src/day03
main-is: Basic.hs
other-modules:
Day3Lib
build-depends: base
, HUnit
, split
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
test-suite day03aoctest
type: exitcode-stdio-1.0
hs-source-dirs: src/day03/test, src/day03
main-is: AoCTest.hs
other-modules:
Day3Lib
build-depends: base
, HUnit
, split
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010

@ -0,0 +1,6 @@
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw

@ -0,0 +1,300 @@
VdzVHmNpdVmBBCpmQLTNfTtMhMJnhFhTTf
FgqsZbqDDFqRrhhJnsnLMTfhJG
bRRRPrRRwSwbDqgjvDZbRbQzpzmQVWCzzBdvQBFCzlWV
GcDdRdvhRssRhGDdShCRtqWjlQzqWgqzNfNjfQWWjt
mwwnnPFwmVrPmJmzfNzqCjQCbgVlgC
nPnHHLrHwmJTrCTJpThBscBSdSLGZvZBvRhZ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BnVVdbRRQJd
vjWPWjWPPPWgwmfCrNvTvZ

@ -0,0 +1,23 @@
module Day3Lib
( score,
--
processInput1,
processInput2,
)
where
import Data.Char (isLower, ord)
import Data.List (intersect)
import Data.List.Split (chunksOf)
score c = if isLower c then ord c - ord 'a' + 1 else ord c - ord 'A' + 27
-- ###################
processInput1 = sum . (map processLine1) . lines
processLine1 r = score . head $ intersect (take ((length r) `div` 2) r) (drop ((length r) `div` 2) r)
processInput2 = sum . (map processChunk2) . (chunksOf 3) . lines
processChunk2 [a, b, c] = score . head . (intersect c) $ intersect a b

@ -0,0 +1,41 @@
import Day3Lib (processInput1, processInput2)
import System.IO
import Test.HUnit
testCases1 =
[ ("data/input030.txt", 157),
("data/input031.txt", 8153)
]
testCase1 (file, result) = do
withFile
file
ReadMode
( \handle -> do
contents <- hGetContents handle
assertEqual "input test" result $ processInput1 contents
)
testCases2 =
[ ("data/input030.txt", 70),
("data/input031.txt", 2342)
]
testCase2 (file, result) = do
withFile
file
ReadMode
( \handle -> do
contents <- hGetContents handle
assertEqual "input test" result $ processInput2 contents
)
tests =
TestList $
[TestCase (testCase1 c) | c <- testCases1]
++ [TestCase (testCase2 c) | c <- testCases2]
main :: IO ()
main = do
runTestTT tests
return ()

@ -0,0 +1,19 @@
import Day3Lib
import Test.HUnit
ta = TestCase (assertEqual "a" 1 $ score 'a')
tz = TestCase (assertEqual "z" 26 $ score 'z')
tA = TestCase (assertEqual "A" 27 $ score 'A')
tZ = TestCase (assertEqual "Z" 52 $ score 'Z')
tests =
TestList $
[ta, tz, tA, tZ]
main :: IO ()
main = do
runTestTT tests
return ()
Loading…
Cancel
Save