diff --git a/app/9.hs b/app/9.hs index 1501151..84ddde8 100644 --- a/app/9.hs +++ b/app/9.hs @@ -37,9 +37,15 @@ fit s t = let (p,a) = break (elem None) s concat p ++ if length (head n) >= length t then t ++ replicate (length n) None ++ concat a' else concat n ++ fit a' t sort2 :: [ℜ] -> [ℜ] -sort2 s = let c = chunks s -- TODO: needs more work here - fitted = fit (init c) (last c) in - if s == fitted then s else sort2 s +sort2 s = let c = chunks s in + if notElem None $ last c + then let fitted = fit (init c) (last c) in + if s == fitted then head c ++ case c of + [] -> [] + [c] -> c + c@[_,_] -> concat c + c -> sort2 (concat . tail $ init c) ++ last c else sort2 fitted + else sort2 (concat $ init c) ++ last c solve :: ([ℜ] -> [ℜ]) -> [ℜ] -> Int solve f s = let fixed = (\case