--- /dev/null
+module one
+
+import StdEnv
+import Data.List
+import StdMaybe
+
+read :: *File -> [Int]
+read f
+ # (ok, i, f) = freadi f
+ | not ok = []
+ = [i:read f]
+
+Start w
+ # (io, w) = stdio w
+ # ls = read io
+ = (one ls, two ls)
+
+one = last o pre
+
+pre l
+ # (preamble, [num:rest]) = splitAt 25 l
+ | isEmpty [()\\a<-preamble, b<-preamble | a + b == num] = [num]
+ = [num:pre (tl l)]
+
+two ls
+ # ls = fst (splitAt 25 ls) ++ pre ls
+ # a = sort (hd (calc (last ls) ls))
+ = (last a + hd a)
+where
+// calc :: Int [Int] -> (Int, Int)
+ calc num xs = hd (filter (not o isEmpty) [calc` num l\\l<-tails xs])
+
+ calc` num xs = filter ((==)num o sum) (dropWhile ((<) num o sum) (inits xs))