Day 12
This commit is contained in:
30
test/Day12Spec.hs
Normal file
30
test/Day12Spec.hs
Normal file
@@ -0,0 +1,30 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Day12Spec (spec) where
|
||||
|
||||
import Day12
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
import Data.Maybe (fromJust, isJust)
|
||||
|
||||
testInput :: String
|
||||
testInput = [str|Sabqponm
|
||||
|abcryxxl
|
||||
|accszExk
|
||||
|acctuvwj
|
||||
|abdefghi
|
||||
|]
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day12" $ do
|
||||
describe "Part1" $ do
|
||||
it "finds a path" $ do
|
||||
let (points, grid) = parseGrid testInput
|
||||
let result = findPath grid points
|
||||
isJust result `shouldBe` True
|
||||
fst (fromJust result) `shouldBe` 31
|
||||
it "finds shortest paths from all lowest points" $ do
|
||||
let (points, grid) = parseGrid testInput
|
||||
let fastest = findBestPath grid points
|
||||
fst fastest `shouldBe` 29
|
||||
Reference in New Issue
Block a user