This commit is contained in:
Matthieu Bessat 2021-12-07 08:40:17 +01:00
parent 6896c62cc8
commit f57e712d38
4 changed files with 6 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View file

@ -26,6 +26,8 @@ minimumsSnd [] = []
minimumsSnd xs = filter ((==) minsnd . snd) xs
where minsnd = minimum (map snd xs)
sumK n = ((n+1)*n) `div` 2
main :: IO ()
main = do
input <- getContents
@ -35,11 +37,11 @@ main = do
splitStr "," input
}
let cases = do {
map (\x -> (x, sum (map (\y -> do {
sum [1..((abs (y-x)))]
}) crabs))) [(minimum crabs)..(maximum crabs)]
map
(\x -> (x, sum (map (\y -> sumK (abs (y-x))) crabs)))
[(minimum crabs)..(maximum crabs)]
}
let min = minimumsSnd
putStrLn $ show $ snd $ head $ min cases -- ans to part 2
-- C'est un code pas du tout efficace
-- Gross, but it works

Binary file not shown.