We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
ParseCharCoords()
1 parent f7b8f2d commit d2eecb7Copy full SHA for d2eecb7
1 file changed
advent_of_code.go/helpers/parsers.go
@@ -1,6 +1,9 @@
1
package helpers
2
3
-import "strings"
+import (
4
+ "strings"
5
+ sets "github.com/deckarep/golang-set/v2"
6
+)
7
8
func ParseOneNumber(data string) int {
9
return Atoi(data)
@@ -46,3 +49,16 @@ func ParseMultiWordsPerLine(data string) [][]string {
46
49
}
47
50
return words
48
51
52
+
53
+func ParseCharCoords(data string) map[rune]sets.Set[[2]int] {
54
+ c := make(map[rune]sets.Set[[2]int])
55
+ for y, line := range strings.Split(data, "\n") {
56
+ for x, char := range line {
57
+ if _, ok := c[char]; !ok {
58
+ c[char] = sets.NewSet[[2]int]()
59
+ }
60
+ c[char].Add([2]int{x, y})
61
62
63
+ return c
64
+}
0 commit comments