183 tokens in Kotlin for part 2 by Valentin Slawicek
Download solution
data
class
Grab
(
val
red
:
Int
,
val
green
:
Int
,
val
blue
:
Int
)
fun
main
(
)
=
println
(
generateSequence
(
::
readLine
)
.
sumOf
{
line
->
val
games
=
line
.
substringAfter
(
"
:
"
)
.
split
(
"
;
"
)
.
map
{
gameString
->
val
red
=
gameString
.
substringBefore
(
"
r
e
d
"
)
.
substringAfterLast
(
"
"
)
.
toIntOrNull
(
)
?:
0
val
green
=
gameString
.
substringBefore
(
"
g
r
e
e
n
"
)
.
substringAfterLast
(
"
"
)
.
toIntOrNull
(
)
?:
0
val
blue
=
gameString
.
substringBefore
(
"
b
l
u
e
"
)
.
substringAfterLast
(
"
"
)
.
toIntOrNull
(
)
?:
0
return@
Grab
(
red
,
green
,
blue
)
}
return@
games
.
maxOf
{
it
.
red
}
*
games
.
maxOf
{
it
.
green
}
*
games
.
maxOf
{
it
.
blue
}
}
)