aoc_go_utils

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

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

func ReadInputAsString(f embed.FS, fname string) string

ReadInputAsString is a helper function for reading in the problem input and converting it to string.

func ReadInputAsStringLines

func ReadInputAsStringLines(f embed.FS, fname string, delim string) []string

ReadInputAsStringLines is a helper function for reading in the problem input and converting it to a slice of strings.

func Reverse

func Reverse[T comparable](input []T)

Reverse flip the order of items in a slice.

func Split

func Split[T any](s []T, ratio float64) ([]T, []T)

Split takes a slice and splits it into two. The caller can specify a `ratio` parameter to change the lengths of each split

func SumInts

func SumInts(ns []int) int

SumInts sums a slice of integers.

func ToInt

func ToInt(s string) int

ToInt is a helper function for casting string values to base 10 integers.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL