File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 4
4
"math"
5
5
"strconv"
6
6
"strings"
7
- "sync"
8
7
)
9
8
10
9
type d16grid struct {
@@ -97,7 +96,6 @@ func (*methods) D16P1(input string) string {
97
96
end : end ,
98
97
area : area ,
99
98
score : int64 (math .MaxInt64 ),
100
- m : & sync.Mutex {},
101
99
cache : make (map [int64 ]int64 ),
102
100
seats : make (map [int64 ][]coords ),
103
101
}
@@ -136,7 +134,6 @@ func (*methods) D16P2(input string) string {
136
134
end : end ,
137
135
area : area ,
138
136
score : int64 (math .MaxInt64 ),
139
- m : & sync.Mutex {},
140
137
cache : make (map [int64 ]int64 ),
141
138
seats : make (map [int64 ][]coords ),
142
139
}
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "fmt"
5
4
"strconv"
6
5
"strings"
7
6
)
@@ -34,8 +33,21 @@ func (*methods) D19P1(input string) string {
34
33
designs := strings .Split (parts [1 ], "\n " )
35
34
36
35
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 {
39
51
possible += d19try (towels , d )
40
52
}
41
53
return strconv .FormatInt (possible , 10 )
You can’t perform that action at this time.
0 commit comments