Name | Language | Tokens Sum | Tokens Part 1 | Tokens Part 2 | Last change | |
---|---|---|---|---|---|---|
1 | LiquidFun | Python | 146 | 88 | 58 | 10 months ago |
2 | anonymous | Kotlin | 227 | 123 | 104 | 11 months ago |
3 | Mustafa Furkan Kaptan | Python | 313 | 170 | 143 | 11 months ago |
4 | Valentin Slawicek | Kotlin | 404 | 221 | 183 | 11 months ago |
data
class
Grab
(
val
red
:
Int
,
val
green
:
Int
,
val
blue
:
Int
)
fun
main
(
)
=
println
(
generateSequence
(
::
readLine
)
.
sumOf
{
line
->
// Parse input
val
gameId
=
line
.
substringBefore
(
"
:
"
)
.
substringAfter
(
"
"
)
.
toInt
(
)
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
)
}
// Check if "possible game"
return@
if
(
games
.
all
{
it
.
red
<=
12
}
&&
games
.
all
{
it
.
green
<=
13
}
&&
games
.
all
{
it
.
blue
<=
14
}
)
{
gameId
}
else
{
0
}
}
)