-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshort_palindrome.hs
More file actions
32 lines (23 loc) · 870 Bytes
/
short_palindrome.hs
File metadata and controls
32 lines (23 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import qualified Data.Map as M
import Data.Functor
import Data.Maybe
data TNode = TNode { tn_rng :: (Int, Int)
, tn_subrngs :: [TNode] }
build_tree :: M.Map Char [Int] -> TNode
build_tree occurances =
let pairs = M.foldl (\acc occ ->
acc ++ [(l, r) | l <- occ, r <- occ, l < r]
) [] occurances
in undefined
solve :: String -> Integer
solve s =
let occurances = foldl (\acc (idx, c) ->
case M.lookup c acc of
Just occ -> M.insert c (idx:occ) acc
Nothing -> M.insert c ([idx]) acc
) M.empty (zip [1..length s] s)
tnode = build_tree occurances
in 0
main = do
s <- getLine
putStrLn $ show $ (solve s) `mod` (1000000000 + 7)