Documentation ¶
Index ¶
- func Contains[T comparable](s []T, value T) bool
- func FindMatches[T comparable](s1, s2 []T) []T
- func Intersect[T comparable](s1, s2 map[T]bool) map[T]bool
- func KeysToSlice[K comparable, V any](m map[K]V) []K
- func ReadInputAsString(f embed.FS, fname string) string
- func ReadInputAsStringLines(f embed.FS, fname string, delim string) []string
- func Reverse[T comparable](input []T)
- func Split[T any](s []T, ratio float64) ([]T, []T)
- func SumInts(ns []int) int
- func ToInt(s string) int
- func ToSet[T comparable](s []T) map[T]bool
- func Union[T comparable](s1, s2 map[T]bool) map[T]bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](s []T, value T) bool
Contains takes a slice and a value and returns true if it exists, else false.
func FindMatches ¶
func FindMatches[T comparable](s1, s2 []T) []T
FindMatches iterates through the items in the shorter slice and returns all the matches that it finds.
func Intersect ¶
func Intersect[T comparable](s1, s2 map[T]bool) map[T]bool
Intersect takes two sets and returns a set with the shared items.
func KeysToSlice ¶
func KeysToSlice[K comparable, V any](m map[K]V) []K
KeysToSlice converts map keys into a slice.
func ReadInputAsString ¶
ReadInputAsString is a helper function for reading in the problem input and converting it to string.
func ReadInputAsStringLines ¶
ReadInputAsStringLines is a helper function for reading in the problem input and converting it to a slice of strings.
func Split ¶
Split takes a slice and splits it into two. The caller can specify a `ratio` parameter to change the lengths of each split
func ToSet ¶
func ToSet[T comparable](s []T) map[T]bool
ToSet takes a slice as input and outputs a set.
func Union ¶
func Union[T comparable](s1, s2 map[T]bool) map[T]bool
Intersect takes two sets and returns a set with the shared items.
Types ¶
This section is empty.