fork download
  1. import Data.List
  2.  
  3. main :: IO ()
  4. main = interact
  5. . map (show . dictIndex)
  6.  
  7. dictIndex :: Ord a => [a] -> Integer
  8. dictIndex = sum
  9. . zipWith ((*) <$> fac) [0..]
  10. . (zipWith countLower <*> tails)
  11. where
  12. countLower :: Ord a => a -> [a] -> Integer
  13. countLower c = genericLength . filter (< c)
  14.  
  15. fac :: Integer -> Integer
  16. fac 0 = 1
  17. fac x = x * fac (x - 1)
Success #stdin #stdout 0s 8388607KB
stdin
Argo
Phineas
Xenophilus
vKbYXZjzsxMfcl7Fu6kaHWhRQE0iqr8dCpoDeUTt2NAwnOPyg51I49LmVJS3GB
WnaojzNv6q1XrSbD8OR4FQKeEU0VTgHYMxJyiP32m5IcZ7utwlshAdBLfC9pGk
Boom
Orthodox
Assassination
stdout
4
302
17641
29103563414182128504865512329269607390047315573979063265767919966424857355013478975571
16646940393791728941964690469055330366549308849162698368036414426663915495795177039268
3
3390
305092339