This is dumb

This commit is contained in:
pingu 2024-12-09 11:11:26 +01:00
parent 397a741931
commit 88e595e5f9

View File

@ -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 concat p ++ if length (head n) >= length t then t ++ replicate (length n) None ++ concat a' else concat n ++ fit a' t
sort2 :: [] -> [] sort2 :: [] -> []
sort2 s = let c = chunks s -- TODO: needs more work here sort2 s = let c = chunks s in
fitted = fit (init c) (last c) in if notElem None $ last c
if s == fitted then s else sort2 s 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 :: ([] -> []) -> [] -> Int
solve f s = let fixed = (\case solve f s = let fixed = (\case