-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (39 loc) · 868 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"github.com/danvolchek/AdventOfCode/lib"
)
func parse(line string) string {
return line
}
func solve(lines []string) int {
sum := 0
for i := 0; i < len(lines); i += 3 {
first := lines[i]
second := lines[i+1]
third := lines[i+2]
outer:
for _, f := range first {
for _, s := range second {
for _, t := range third {
if f == s && s == t {
if f >= 'a' && f <= 'z' {
sum += int(f-'a') + 1
} else {
sum += int(f-'A') + 27
}
break outer
}
}
}
}
}
return sum
}
func main() {
solver := lib.Solver[[]string, int]{
ParseF: lib.ParseLine(parse),
SolveF: solve,
}
solver.Expect("vJrwpWtwJgWrhcsFMMfFFhFp\njqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL\nPmmdzqPrVvPwwTWBwg\nwMqvLMZHhHMvwLHjbvcjnnSBnvTQFn\nttgJtRGJQctTZtZT\nCrZsJsPPZsGzwwsLwLmpwMDw", 70)
solver.Verify(2567)
}