util

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 4 Imported by: 1

README

Utility package

English -> Pig Latin Translation Rules

A word with no characters is unchanged.

  • If a word begins with a vowel sound, do not shift the letters. Note that "xr" and "yt" at the beginning of a word make vowel sounds (e.g. "xray" -> "xrayay", "yttria" -> "yttriaay"). Add 'way' to the end of the word.

  • If a word begins with a consonant sound, move it to the end of the word. Consonant sounds can be made up of multiple consonants, such as the "ch" in "chair" or "st" in "stand" (e.g. "chair" -> "airchay"). If a word starts with a consonant sound followed by "qu", also move the 'u' to the end of the word (e.g. "square" -> "aresquay"). Add 'ay' to the end of the word.

  • If a word contains a "y" after a consonant cluster or as the second letter in a two letter word the 'y' makes a vowel sound (e.g. "rhythm" -> "ythmrhay", "my" -> "ymay").

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convergent

func Convergent(n int, fn convergentSeries) (*big.Int, *big.Int)

Convergent returns the nth convegence of whichever series you pass in a function for

func Cryptoquip

func Cryptoquip(w1, w2 string) (map[byte]byte, bool)

Cryptoquip returns true if the letter arrangements are similar; e.g., KEEP and LOOT

func DigitSum

func DigitSum(n int) (sum int)

DigitSum returns the sum of the digits in the number

func DigitsToInt

func DigitsToInt(digits []int) int

DigitsToInt converts a slice of digits to an int

func Divisors

func Divisors(n int) []int

Divisors returns a sorted list of all positive divisors of n

func E

func E(n int) int64

E returns the nth number (1-based) in the convergent series of e

func Equal

func Equal(a, b []int) bool

Equal returns true if the two slices have identical contents

func Factors

func Factors(n int) []int

Factors returns a sorted list of the unique prime factors of n (excluding n)

func FactorsCounted

func FactorsCounted(n int) map[int]int

FactorsCounted returns counts of how many times each factor divides into n

func GCD added in v0.0.2

func GCD(a, b int) int

GCD returns the greatest common divisor of a and b

func Harshad

func Harshad(n, sum int) bool

Harshad returns true if n is divisible by the sum of its digits

func IntToDigits

func IntToDigits(n int) []int

IntToDigits converts an int into a slice of its component digits

func IsAnagram

func IsAnagram(w1, w2 string) bool

IsAnagram returns true if w1 and w2 are anagrams of each other

func IsCube added in v0.0.4

func IsCube(n int) bool

IsCube returns true if n is a cube number

func IsDigitPermutation added in v0.0.7

func IsDigitPermutation(a, b int) bool

IsDigitPermutation returns whether the two numbers are digit permutations of each other

func IsInt added in v0.0.4

func IsInt(n float64) bool

IsInt returns true if n is an integer

func IsPalindromeInt

func IsPalindromeInt(p []int) bool

IsPalindromeInt returns true if the digits of p are a palindrome

func IsPalindromeString

func IsPalindromeString(p string) bool

IsPalindromeString returns true if the string is a palindrome

func IsSquare

func IsSquare(n int) bool

IsSquare returns true if n is a square number

func LCM added in v0.0.2

func LCM(a, b int) int

LCM returns the least common multiple of a and b

func MakeDigits

func MakeDigits(n int, c chan []int)

MakeDigits generates all permutations of the first n digits

func MulFraction added in v0.0.4

func MulFraction(n1, d1, n2, d2 int) (int, int)

MulFraction returns the product of the two fractions, still in fraction form

func PascalTriangle

func PascalTriangle(max int) [][]int

PascalTriangle returns a triangle of the max depth specified

func ReduceFraction added in v0.0.4

func ReduceFraction(n, d int) (int, int)

func Reverse

func Reverse(digits []int) []int

Reverse reverses the order of the elements in a slice

func Sqrt2

func Sqrt2(n int) int64

Sqrt2 returns the nth number (1-based) in the convergent series of root 2

func SquareFree

func SquareFree(n int) bool

SquareFree returns true if no square of a prime divides n

func SumFraction added in v0.0.2

func SumFraction(n1, d1, n2, d2 int) (int, int)

SumFraction returns the sum of the two fractions, still in fraction form

func Totient

func Totient(n int) int

Totient returns how many numbers k are relatively prime to n

Types

This section is empty.

Jump to

Keyboard shortcuts

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