parent
54c97ceb71
commit
44a48767ef
|
@ -0,0 +1,21 @@
|
|||
import Control.Arrow
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
input <- map read . lines <$> readFile "input"
|
||||
print $ (product . map length . group . sort . jolts) input
|
||||
print $
|
||||
(product . map (arrangements . sum) . filter (elem 1) . group . jolts) input
|
||||
|
||||
arrangements :: Int -> Int
|
||||
arrangements n =
|
||||
length $
|
||||
filter (== n) $ map sum $ nub $ map (filter (/= 0)) $ replicateM n [0 .. 3]
|
||||
|
||||
jolts :: [Int] -> [Int]
|
||||
jolts =
|
||||
map (uncurry subtract) .
|
||||
ap zip tail .
|
||||
uncurry (++) . (id &&& (flip (:) [] . (+ 3) . last)) . (:) 0 . sort
|
|
@ -0,0 +1,95 @@
|
|||
99
|
||||
3
|
||||
1
|
||||
11
|
||||
48
|
||||
113
|
||||
131
|
||||
43
|
||||
82
|
||||
19
|
||||
4
|
||||
153
|
||||
105
|
||||
52
|
||||
56
|
||||
109
|
||||
27
|
||||
119
|
||||
147
|
||||
31
|
||||
34
|
||||
13
|
||||
129
|
||||
17
|
||||
61
|
||||
10
|
||||
29
|
||||
24
|
||||
12
|
||||
104
|
||||
152
|
||||
103
|
||||
80
|
||||
116
|
||||
79
|
||||
73
|
||||
21
|
||||
133
|
||||
44
|
||||
18
|
||||
74
|
||||
112
|
||||
136
|
||||
30
|
||||
146
|
||||
100
|
||||
39
|
||||
130
|
||||
91
|
||||
124
|
||||
70
|
||||
115
|
||||
81
|
||||
28
|
||||
151
|
||||
2
|
||||
122
|
||||
87
|
||||
143
|
||||
62
|
||||
7
|
||||
126
|
||||
95
|
||||
75
|
||||
20
|
||||
123
|
||||
63
|
||||
125
|
||||
53
|
||||
45
|
||||
141
|
||||
14
|
||||
67
|
||||
69
|
||||
60
|
||||
114
|
||||
57
|
||||
142
|
||||
150
|
||||
42
|
||||
78
|
||||
132
|
||||
66
|
||||
88
|
||||
140
|
||||
139
|
||||
106
|
||||
38
|
||||
85
|
||||
37
|
||||
51
|
||||
94
|
||||
98
|
||||
86
|
||||
68
|
|
@ -0,0 +1,11 @@
|
|||
16
|
||||
10
|
||||
15
|
||||
5
|
||||
1
|
||||
11
|
||||
7
|
||||
19
|
||||
6
|
||||
12
|
||||
4
|
|
@ -0,0 +1,31 @@
|
|||
28
|
||||
33
|
||||
18
|
||||
42
|
||||
31
|
||||
14
|
||||
46
|
||||
20
|
||||
48
|
||||
47
|
||||
24
|
||||
23
|
||||
49
|
||||
45
|
||||
19
|
||||
38
|
||||
39
|
||||
11
|
||||
1
|
||||
32
|
||||
25
|
||||
35
|
||||
8
|
||||
17
|
||||
7
|
||||
9
|
||||
4
|
||||
2
|
||||
34
|
||||
10
|
||||
3
|
Loading…
Reference in New Issue
Block a user