--- /dev/null
+# This YAML file describes your package. Stack will automatically generate a
+# Cabal file when you run `stack build`. See the hpack website for help with
+# this file: <https://github.com/sol/hpack>.
+
+name: advent04
+synopsis: Advent of Code
+version: '0.0.1'
+
+default-extensions:
+- AllowAmbiguousTypes
+- ApplicativeDo
+- BangPatterns
+- BlockArguments
+- DataKinds
+- DeriveFoldable
+- DeriveFunctor
+- DeriveGeneric
+- DeriveTraversable
+- EmptyCase
+- FlexibleContexts
+- FlexibleInstances
+- FunctionalDependencies
+- GADTs
+- GeneralizedNewtypeDeriving
+- ImplicitParams
+- KindSignatures
+- LambdaCase
+- MonadComprehensions
+- MonoLocalBinds
+- MultiParamTypeClasses
+- MultiWayIf
+- NegativeLiterals
+- NumDecimals
+- OverloadedLists
+- OverloadedStrings
+- PartialTypeSignatures
+- PatternGuards
+- PatternSynonyms
+- PolyKinds
+- RankNTypes
+- RecordWildCards
+- ScopedTypeVariables
+- TemplateHaskell
+- TransformListComp
+- TupleSections
+- TypeApplications
+- TypeInType
+- TypeOperators
+- ViewPatterns
+
+
+executables:
+ advent04:
+ main: advent04.hs
+ source-dirs: src
+ dependencies:
+ - base >= 2 && < 6
--- /dev/null
+
+main :: IO ()
+main = do
+ print part1
+ print part2
+
+lowerLimit = 134792
+upperLimit = 675810
+
+
+part1 = length $ filter inRange $ filter adjacentSame candidates
+part2 = length $ filter isolatedAdjacentSame $ filter inRange $ filter adjacentSame candidates
+
+inRange digits = n >= lowerLimit && n <= upperLimit
+ where n = numify digits
+
+numify :: (Int, Int, Int, Int, Int, Int) -> Int
+numify (d1, d2, d3, d4, d5, d6) =
+ d1 * 10^5 + d2 * 10^4 + d3 * 10^3 + d4 * 10^2 + d5 * 10 + d6
+
+adjacentSame (d1, d2, d3, d4, d5, d6) =
+ d1 == d2 || d2 == d3 || d3 == d4 || d4 == d5 || d5 == d6
+
+isolatedAdjacentSame (d1, d2, d3, d4, d5, d6) =
+ (d1 == d2 && d2 /= d3)
+ || (d1 /= d2 && d2 == d3 && d3 /= d4)
+ || (d2 /= d3 && d3 == d4 && d4 /= d5)
+ || (d3 /= d4 && d4 == d5 && d5 /= d6)
+ || (d4 /= d5 && d5 == d6)
+
+
+candidates = [ (d1, d2, d3, d4, d5, d6)
+ | d1 <- [1..6]
+ , d2 <- [d1..9]
+ , d3 <- [d2..9]
+ , d4 <- [d3..9]
+ , d5 <- [d4..9]
+ , d6 <- [d5..9]
+ ]
+
\ No newline at end of file