Skip to content

Commit 7e60c47

Browse files
committed
fix d16 & d19
1 parent ab7d60e commit 7e60c47

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

d16.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"math"
55
"strconv"
66
"strings"
7-
"sync"
87
)
98

109
type d16grid struct {
@@ -97,7 +96,6 @@ func (*methods) D16P1(input string) string {
9796
end: end,
9897
area: area,
9998
score: int64(math.MaxInt64),
100-
m: &sync.Mutex{},
10199
cache: make(map[int64]int64),
102100
seats: make(map[int64][]coords),
103101
}
@@ -136,7 +134,6 @@ func (*methods) D16P2(input string) string {
136134
end: end,
137135
area: area,
138136
score: int64(math.MaxInt64),
139-
m: &sync.Mutex{},
140137
cache: make(map[int64]int64),
141138
seats: make(map[int64][]coords),
142139
}

d19.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"fmt"
54
"strconv"
65
"strings"
76
)
@@ -34,8 +33,21 @@ func (*methods) D19P1(input string) string {
3433
designs := strings.Split(parts[1], "\n")
3534

3635
var possible int64
37-
for i, d := range designs {
38-
fmt.Printf("%d/%d\n", i+1, len(designs))
36+
for _, d := range designs {
37+
if d19try(towels, d) > 0 {
38+
possible++
39+
}
40+
}
41+
return strconv.FormatInt(possible, 10)
42+
}
43+
44+
func (*methods) D19P2(input string) string {
45+
parts := strings.Split(input, "\n\n")
46+
towels := strings.Split(parts[0], ",")
47+
designs := strings.Split(parts[1], "\n")
48+
49+
var possible int64
50+
for _, d := range designs {
3951
possible += d19try(towels, d)
4052
}
4153
return strconv.FormatInt(possible, 10)

0 commit comments

Comments
 (0)