Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Gehrke
aoc-2020
Commits
987a9bfd
Commit
987a9bfd
authored
Dec 06, 2020
by
Alexander Gehrke
Browse files
[day6] solution
parent
0dc106ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/scala/Day6.scala
0 → 100644
View file @
987a9bfd
package
aoc2020
import
aoc2020.lib._
def
day6
(
input
:
List
[
String
])
:
String
=
//countGroupAnswersAny(input).sum.toString
countGroupAnswersAll
(
input
).
sum
.
toString
def
countGroupAnswersAny
(
input
:
List
[
String
])
:
LazyList
[
Int
]
=
input
.
split
(
""
).
map
(
_
.
flatMap
(
_
.
toArray
).
toSet
.
size
)
def
countGroupAnswersAll
(
input
:
List
[
String
])
:
LazyList
[
Int
]
=
input
.
split
(
""
).
map
(
lines
=>
{
val
answers
=
lines
.
map
(
_
.
toSet
)
answers
.
headOption
.
map
(
h
=>
answers
.
tail
.
fold
(
h
)(
_
intersect
_
))
.
map
(
_
.
size
)
.
getOrElse
(
0
)
})
src/main/scala/Main.scala
View file @
987a9bfd
...
...
@@ -7,5 +7,6 @@ package aoc2020
case
3
=>
input
(
boolChar
(
'#'
))(
day3
)
case
4
=>
input
()(
day4
)
case
5
=>
input
()(
day5
)
case
6
=>
input
()(
day6
)
}
println
(
out
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment