-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (40 loc) · 677 Bytes
/
main.go
File metadata and controls
54 lines (40 loc) · 677 Bytes
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
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]
}
}
found := 0
q := 0
for k := 0; k < len(grid); k++ {
if grid[k][q%len(grid[k])] == '#' {
found++
}
q += 3
}
fmt.Println(found)
}
func main() {
input, err := os.Open(path.Join("2020", "3", "input.txt"))
if err != nil {
panic(err)
}
solve(input)
}