Skip to content
loading...

re: Daily Challenge #187 - Most Sales VIEW POST

FULL DISCUSSION
 

Haskell

module MostSales where

import Data.List (groupBy, head, zip3, sortBy)


findHighest :: [String] -> [Int] -> [Int] -> [String]
findHighest a b c =
    ((map fst) . head . (groupBy value) . (sortBy compare') . (map total)) $ (zip3 a b c)
    where
        total (n, a, b)        = (n, a * b)
        value (_, x)           = ((==) x . snd)
        compare' (_, a) (_, b) = compare b a
code of conduct - report abuse