Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
import Data.List (inits, intercalate, transpose)
|
||||
import qualified Data.Set as S
|
||||
|
||||
--------------- MINIMUM ABBREVIATION LENGTH --------------
|
||||
|
||||
minAbbrevnLength :: [String] -> Int
|
||||
minAbbrevlnLength [] = 0
|
||||
minAbbrevnLength xs =
|
||||
length . head . S.toList . head $
|
||||
dropWhile ((< n) . S.size) $
|
||||
S.fromList
|
||||
<$> transpose (inits <$> xs)
|
||||
where
|
||||
n = length xs
|
||||
|
||||
--------------------------- TEST -------------------------
|
||||
main :: IO ()
|
||||
main = do
|
||||
s <- readFile "./weekDayNames.txt"
|
||||
mapM_ putStrLn $
|
||||
take 10 $
|
||||
intercalate "\t"
|
||||
. (<*>)
|
||||
[ show . minAbbrevnLength . words,
|
||||
id
|
||||
]
|
||||
. return
|
||||
<$> lines s
|
||||
Loading…
Add table
Add a link
Reference in a new issue