aoc/internal/utility/utility.go

40 lines
480 B
Go
Raw Normal View History

2024-07-24 18:03:39 +00:00
package utility
import (
"crypto/md5"
"encoding/hex"
"log"
)
type AdventRunner interface {
Run(int)
}
func E(err error) {
if err != nil {
log.Panic(err)
}
}
type Point struct {
x int
y int
}
func NewPoint(x, y int) Point {
return Point{x, y}
}
func GetMD5Hash(in string) string {
hash := md5.Sum([]byte(in))
return hex.EncodeToString(hash[:])
}
func RuneMap(in string) (m map[rune]int) {
m = make(map[rune]int)
for _, c := range in {
m[c]++
}
return m
}