aoc24/util/slices.go
mstar 7d63141f07 Day 5 done
I'm a fucking idiot and made it harder for myself than it had to be
Go's sorting function already takes care of the actual sort, I just had
to tell it how two elements compare according to the rules
2024-12-05 12:50:54 +01:00

12 lines
187 B
Go

package util
func RemoveFromSlice[T any](s []T, i int) []T {
s[i] = s[len(s)-1]
return s[:len(s)-1]
}
func SliceSwap[T any](s []T, x, y int) {
tmp := s[x]
s[x] = s[y]
s[y] = tmp
}