File tree 1 file changed +4
-18
lines changed 1 file changed +4
-18
lines changed Original file line number Diff line number Diff line change @@ -62,20 +62,6 @@ parse2 string =
62
62
-- 3. COMPUTE (actually solve the problem)
63
63
64
64
65
- rules1 : List (List Char -> Bool )
66
- rules1 =
67
- [ twoOrMore
68
- , ruleMonotonic
69
- ]
70
-
71
-
72
- rules2 : List (List Char -> Bool )
73
- rules2 =
74
- [ atLeastOneTwo
75
- , ruleMonotonic
76
- ]
77
-
78
-
79
65
twoOrMore : List Char -> Bool
80
66
twoOrMore digits =
81
67
List . Extra . group digits
@@ -94,8 +80,8 @@ atLeastOneTwo digits =
94
80
|> (/=) 0
95
81
96
82
97
- ruleMonotonic : List Char -> Bool
98
- ruleMonotonic digits =
83
+ monotonic : List Char -> Bool
84
+ monotonic digits =
99
85
List . Extra . groupWhile (<=) digits
100
86
|> List . length
101
87
|> (==) 1
@@ -116,7 +102,7 @@ compute1 ( low, high ) =
116
102
digits =
117
103
toChars n
118
104
in
119
- if List . all ( \ rule -> rule digits) rules1 then
105
+ if twoOrMore digits && monotonic digits then
120
106
Just n
121
107
122
108
else
@@ -135,7 +121,7 @@ compute2 ( low, high ) =
135
121
digits =
136
122
toChars n
137
123
in
138
- if List . all ( \ rule -> rule digits) rules2 then
124
+ if atLeastOneTwo digits && monotonic digits then
139
125
Just n
140
126
141
127
else
You can’t perform that action at this time.
0 commit comments