From: Mart Lubbers Date: Thu, 10 Dec 2020 07:22:25 +0000 (+0100) Subject: one line X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=622c2b5f937d448cd0a1693874cc98735535094a;p=aoc20.git one line --- diff --git a/10/one.icl b/10/one.icl index 32ffe8b..a71ff6d 100644 --- a/10/one.icl +++ b/10/one.icl @@ -16,10 +16,6 @@ Start w # ls = sort [0:read io] = (one ls, two 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) +one ls = prod $ map length $ group $ sort [3:[b-a\\a<-ls & b<-tl ls]] 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]