2.1
[advent18.git] / 2 / s1.icl
diff --git a/2/s1.icl b/2/s1.icl
new file mode 100644 (file)
index 0000000..af6361e
--- /dev/null
+++ b/2/s1.icl
@@ -0,0 +1,27 @@
+module s1
+
+import StdEnv
+
+import Data.Func
+import Data.List
+import Data.Tuple
+
+getinput f
+# (ok, c, f) = freadc f
+| not ok = []
+= [c:getinput f]
+
+split :: [Char] [Char] -> [[Char]]
+split [] [] = []
+split c [] = [reverse c]
+split c ['\n':rest] = [reverse c:split [] rest]
+split c [r:rest] = split [r:c] rest
+
+Start w
+# (io, w) = stdio w
+# l = map (nub o map length o group o sort)
+       $ split []
+       $ getinput io
+= ns 2 l * ns 3 l
+
+ns n l = sum [1\\x<-l|isMember n x]