-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3.go
30 lines (22 loc) · 811 Bytes
/
day3.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
package day3
import "fmt"
// Day3Solution1 finds the number of tress in a path on the slope right 3, down 1
func Day3Solution1(input []string, results chan string) {
slope := buildTreeMap(input)
treesHit := findTreesOnPath(slope, 3, 1)
results <- fmt.Sprintf("part1: hit %v trees", treesHit)
}
// Day3Solution2 WIP
func Day3Solution2(input []string, results chan string) {
slope := buildTreeMap(input)
r1d1 := findTreesOnPath(slope, 1, 1)
resetSlope(slope)
r3d1 := findTreesOnPath(slope, 3, 1)
resetSlope(slope)
r5d1 := findTreesOnPath(slope, 5, 1)
resetSlope(slope)
r7d1 := findTreesOnPath(slope, 7, 1)
resetSlope(slope)
r1d2 := findTreesOnPath(slope, 1, 2)
results <- fmt.Sprintf("part2: tress hit: %v * %v * %v * %v * %v = %v", r1d1, r3d1, r5d1, r7d1, r1d2, r1d1*r3d1*r5d1*r7d1*r1d2)
}