packages feed

advent-of-code-ocr-0.1.0.0: test/Spec.hs

{-# LANGUAGE QuasiQuotes #-}

import           Advent.OCR
import           Test.Hspec
import           Text.Heredoc
import qualified Data.Set     as S

main :: IO ()
main = hspec $ do
    describe "2016 Day 8" $ do
      it "should parse a sample result correctly" $ do
        asciiMapToLetters (S.singleton '#') y2016d08
            `shouldBe` Just "ZJHRKCPLYJ"
    describe "2018 Day 10" $ do
      it "should parse a sample result correctly" $ do
        asciiMapToLetters (S.singleton '#') y2018d10
            `shouldBe` Just "AHZLLCAL"
    describe "2019 Day 8" $ do
      it "should parse a sample result correctly" $ do
        asciiMapToLetters (S.singleton '#') y2019d08
            `shouldBe` Just "UBUFP"
    describe "2019 Day 11" $ do
      it "should parse a sample result correctly, even mirrored" $ do
        asciiMapToLetters (S.singleton '#') y2019d11
            `shouldBe` Just "JKZLZJBH"

y2016d08 :: String
y2016d08 = drop 1 [here|
####...##.#..#.###..#..#..##..###..#....#...#..##
...#....#.#..#.#..#.#.#..#..#.#..#.#....#...#...#
..#.....#.####.#..#.##...#....#..#.#.....#.#....#
.#......#.#..#.###..#.#..#....###..#......#.....#
#....#..#.#..#.#.#..#.#..#..#.#....#......#..#..#
####..##..#..#.#..#.#..#..##..#....####...#...##.
|]

y2018d10 :: String
y2018d10 = drop 1 [here|
..##....#....#..######..#.......#........####.....##....#.....
.#..#...#....#.......#..#.......#.......#....#...#..#...#.....
#....#..#....#.......#..#.......#.......#.......#....#..#.....
#....#..#....#......#...#.......#.......#.......#....#..#.....
#....#..######.....#....#.......#.......#.......#....#..#.....
######..#....#....#.....#.......#.......#.......######..#.....
#....#..#....#...#......#.......#.......#.......#....#..#.....
#....#..#....#..#.......#.......#.......#.......#....#..#.....
#....#..#....#..#.......#.......#.......#....#..#....#..#.....
#....#..#....#..######..######..######...####...#....#..######
|]

y2019d08 :: String
y2019d08 = drop 1 [here|
#..#.###..#..#.####.###.
#..#.#..#.#..#.#....#..#
#..#.###..#..#.###..#..#
#..#.#..#.#..#.#....###.
#..#.#..#.#..#.#....#...
.##..###...##..#....#...
|]

y2019d11 :: String
y2019d11 = drop 1 [here|
.##..#..#.####.####.####..##..###..#..#
#..#.#.#..#....#....#....#..#.#..#.#..#
...#.#.#...#...#.....#......#.#..#.#..#
...#.##.....#..#......#.....#.###..####
...#.#.#.....#.#.......#....#.#..#.#..#
..##.#..#.####.#....####...##.###..#..#
|]