2023-12-01 19:32:06 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
const input = os.read_file('./input.txt')!
|
2023-12-01 23:42:44 +01:00
|
|
|
//const input = "1abc2
|
|
|
|
//pqr3stu8vwx
|
|
|
|
//a1b2c3d4e5f
|
|
|
|
//treb7uchet"
|
2023-12-01 19:32:06 +01:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
lines := input.split('\n')
|
|
|
|
mut sum := 0
|
|
|
|
|
|
|
|
for line in lines {
|
|
|
|
if line.is_blank() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
trimmed := line.trim('abcdefghijklmnopqrstuvwxyz')
|
|
|
|
n := trimmed[0].ascii_str() + trimmed[trimmed.len-1].ascii_str()
|
|
|
|
sum += n.int()
|
|
|
|
}
|
|
|
|
|
|
|
|
println("Result is ${sum}")
|
|
|
|
}
|