Name | Language | Tokens Sum | Tokens Part 1 | Tokens Part 2 | Last change | |
---|---|---|---|---|---|---|
1 | FSFabian Schedler | Kotlin | 318 | 156 | 162 | 11 months ago |
fun
main
(
)
=
println
(
generateSequence
(
::
readLine
)
.
toList
(
)
.
run
{
val
rowsToExpand
=
indices
.
filter
{
y
->
'
#
'
!in
this
[
y
]
}
val
columnsToExpand
=
indices
.
filter
{
x
->
none
{
it
[
x
]
==
'
#
'
}
}
flatMapIndexed
{
y
,
row
->
row
.
mapIndexedNotNull
{
x
,
value
->
if
(
value
!=
'
#
'
)
null
else
y
+
rowsToExpand
.
count
{
it
<
y
}
to
x
+
columnsToExpand
.
count
{
it
<
x
}
}
}
.
run
{
flatMap
{
map
(
it
::
to
)
}
}
.
sumOf
{
it
.
run
{
Math
.
abs
(
first
.
first
-
second
.
first
)
+
Math
.
abs
(
first
.
second
-
second
.
second
)
}
}
/
2
}
)