23 lines
456 B
Kotlin
23 lines
456 B
Kotlin
package main
|
|
|
|
import java.io.File
|
|
|
|
fun main() {
|
|
var sum = 0
|
|
File("../input.txt").forEachLine{
|
|
var firstDigit = ""
|
|
var lastDigit = ""
|
|
|
|
for (c in it) {
|
|
if (c.isDigit()) {
|
|
lastDigit = c.toString()
|
|
if (firstDigit == "") {
|
|
firstDigit = c.toString()
|
|
}
|
|
}
|
|
}
|
|
|
|
sum += (firstDigit + lastDigit).toInt()
|
|
}
|
|
println(sum)
|
|
}
|