-
Notifications
You must be signed in to change notification settings - Fork 0
/
day2.go
55 lines (46 loc) · 787 Bytes
/
day2.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
50
51
52
53
54
55
package main
import (
"fmt"
"os"
"strings"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
combination1 := map[string]int{
"A X": 1 + 3,
"A Y": 2 + 6,
"A Z": 3 + 0,
"B X": 1 + 0,
"B Y": 2 + 3,
"B Z": 3 + 6,
"C X": 1 + 6,
"C Y": 2 + 0,
"C Z": 3 + 3,
}
combination2 := map[string]int{
"A X": 3 + 0,
"A Y": 1 + 3,
"A Z": 2 + 6,
"B X": 1 + 0,
"B Y": 2 + 3,
"B Z": 3 + 6,
"C X": 2 + 0,
"C Y": 3 + 3,
"C Z": 1 + 6,
}
input, err := os.ReadFile("./input/input2.txt")
check(err)
lines := strings.Split(string(input), "\r\n")
points1 := 0
points2 := 0
for _, line := range lines {
points1 += combination1[line]
points2 += combination2[line]
}
fmt.Println("part 1: ", points1)
fmt.Println("part 2: ", points2)
}