arrays

package
v0.0.0-...-9a25d2e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAnagramArray

func IsAnagramArray(a, b string) bool

Expect ASCII chars only

Example (Output)
anagramTests := [][2]string{
	{"heart", "earth"},
	{"checklen", "oops"},
	{"heart", "bartch"},
	{"", ""},
}

var actual bool
for _, in := range anagramTests {
	actual = IsAnagramArray(in[0], in[1])

	fmt.Printf("IsAnagramArray of '%s' and '%s' returns %v\n", in[0], in[1], actual)
}
Output:

IsAnagramArray of 'heart' and 'earth' returns true
IsAnagramArray of 'checklen' and 'oops' returns false
IsAnagramArray of 'heart' and 'bartch' returns false
IsAnagramArray of '' and '' returns true

func IsAnagramMap

func IsAnagramMap(a, b string) bool
Example (Output)
anagramTests := [][2]string{
	{"heart", "earth"},
	{"checklen", "oops"},
	{"heart", "bartch"},
	{"", ""},
}

var actual bool
for _, in := range anagramTests {
	actual = IsAnagramMap(in[0], in[1])

	fmt.Printf("IsAnagramMap of '%s' and '%s' returns %v\n", in[0], in[1], actual)
}
Output:

IsAnagramMap of 'heart' and 'earth' returns true
IsAnagramMap of 'checklen' and 'oops' returns false
IsAnagramMap of 'heart' and 'bartch' returns false
IsAnagramMap of '' and '' returns true

func UniqChars

func UniqChars(s string) bool
Example (Output)
tt := []string{
	"abcd",
	"dcba",
	"aabbcc",
	"ZAaz",
}

var actual bool
for _, in := range tt {
	actual = UniqChars(in)
	fmt.Printf("%s: %v\n", in, actual)
}
Output:

abcd: true
dcba: true
aabbcc: false
ZAaz: true

Types

This section is empty.

Jump to

Keyboard shortcuts

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