mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2026-04-08 18:13:36 +00:00
add daythree + benchmarks
This commit is contained in:
25
day-03/internal/util/util.go
Normal file
25
day-03/internal/util/util.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetGroups(r *regexp.Regexp, s string) map[string]string {
|
||||
groups := make(map[string]string)
|
||||
names := r.SubexpNames()
|
||||
for i, res := range r.FindStringSubmatch(s) {
|
||||
if i != 0 {
|
||||
groups[names[i]] = res
|
||||
}
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
func MustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
Reference in New Issue
Block a user