import qualified Data.Sequence as Q
-import Data.Sequence ((<|), (|>))
-import Data.List
+import Data.Sequence ((|>))
import Data.Foldable (toList)
type Recipes = Q.Seq Int
part2 state0 = if (takeR (Q.length targetSeq) recipes) == targetSeq
then (Q.length recipes) - (Q.length targetSeq)
else (Q.length recipes) - (Q.length targetSeq) - 1
--- recipes -- (Q.length recipes) - (Q.length targetSeq)
-
where (State _ _ recipes) = head $ dropWhile (unfinished2 targetSeq) $ states state0
unfinished2 :: Recipes -> State -> Bool