-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
64 lines (47 loc) · 790 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"encoding/csv"
"fmt"
"io"
"os"
"path"
)
func solve(r io.Reader) {
csvReader := csv.NewReader(r)
rows, err := csvReader.ReadAll()
if err != nil {
panic(err)
}
var grid [][]byte
grid = make([][]byte, len(rows))
for i, row := range rows {
actual := row[0]
grid[i] = make([]byte, len(actual))
for j := 0; j < len(actual); j++ {
grid[i][j] = actual[j]
}
}
big := 1
for i, item := range []int{1, 3, 5, 7, 1} {
found := 0
q := 0
for k := 0; k < len(rows); k++ {
if grid[k][q%len(grid[k])] == '#' {
found++
}
q += item
if i == 4 {
k++
}
}
big *= found
}
fmt.Println(big)
}
func main() {
input, err := os.Open(path.Join("2020", "3", "input.txt"))
if err != nil {
panic(err)
}
solve(input)
}