[Rust] 11157/6740
use std::fs;
const m: [(&str, u32); 10] = [
("zero", 0),
("one", 1),
("two", 2),
("three", 3),
("four", 4),
("five", 5),
("six", 6),
("seven", 7),
("eight", 8),
("nine", 9)
];
fn main() {
let s = fs::read_to_string("data/input.txt").unwrap();
let mut u = 0;
for l in s.lines() {
let mut h = l.chars();
let mut f = 0;
let mut a = 0;
for n in 0..l.len() {
let u = h.next().unwrap();
match u.is_numeric() {
true => {
let v = u.to_digit(10).unwrap();
if f == 0 {
f = v;
}
a = v;
},
_ => {
for (t, v) in m {
if l[n..].starts_with(t) {
if f == 0 {
f = v;
}
a = v;
}
}
},
}
}
u += f * 10 + a;
}
println!("Sum: {}", u);
}
Started a bit late due to setting up the thread and monitoring the leaderboard to open it up but still got it decently quick for having barely touched rust
Probably able to get it down shorter so might revisit it