day 1, part 1
This commit is contained in:
commit
b048d63227
3 changed files with 1048 additions and 0 deletions
1000
01/input.txt
Normal file
1000
01/input.txt
Normal file
File diff suppressed because it is too large
Load diff
20
01/part1.v
Normal file
20
01/part1.v
Normal file
|
@ -0,0 +1,20 @@
|
|||
import os
|
||||
|
||||
const input = os.read_file('./input.txt')!
|
||||
|
||||
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}")
|
||||
}
|
28
01/part2.v
Normal file
28
01/part2.v
Normal file
|
@ -0,0 +1,28 @@
|
|||
import os
|
||||
|
||||
//const input = os.read_file('./input.txt')!
|
||||
|
||||
const input = "two1nine
|
||||
eightwothree
|
||||
abcone2threexyz
|
||||
xtwone3four
|
||||
4nineeightseven2
|
||||
zoneight234
|
||||
7pqrstsixteen"
|
||||
|
||||
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}")
|
||||
}
|
Loading…
Reference in a new issue