import StdEnv
+import Data.List
+import Data.Func
+
read :: *File -> [Int]
read f
# (ok, i, f) = freadi f
# ls = sort [0:read io]
= (one ls, two ls)
-one ls = uncurry (*) (foldl jolt (0, 1) [b-a\\a<-ls & b<-tl ls])
+one ls = uncurry (*) $ foldl jolt (0, 1) [b-a\\a<-ls & b<-tl ls]
where
jolt (j1, j3) 3 = (j1, j3+1)
jolt (j1, j3) 1 = (j1+1, j3)
jolt (j1, j3) _ = (j1, j3)
-two [a,b,c,d,e,f,g,h,i:xs]
- | i-a <= 9 = 53 * two xs
-two [a,b,c,d,e,f,g,h:xs]
- | h-a <= 8 = 33 * two xs
-two [a,b,c,d,e,f,g:xs]
- | g-a <= 7 = 20 * two xs
-two [a,b,c,d,e,f:xs]
- | f-a <= 6 = 12 * two xs
-two [a,b,c,d,e:xs]
- | e-a <= 5 = 7 * two xs
-two [a,b,c,d:xs]
- | d-a <= 4 = 4 * two xs
-two [a,b,c:xs]
- | c-a <= 3 = 2 * two xs
-two [x:xs] = two xs
-two [] = 1
+two ls = prod [[0,1,2,4,7,12,20,33,53]!!length l\\l<-group [b-a\\a<-ls & b<-tl ls] | all ((==)1) l]