Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

ymhhh/algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

algorithm

  • Build Status

Hash

Hash Repo

type HashRepo interface {
	// checksum string once
	Sum(s string) string
	// checksum bytes once
	SumBytes(bs []byte) string
	// checksum string more times
	SumTimes(s string, times uint) string
	// checksum bytes more times
	SumBytesTimes(bs []byte, times uint) string
}

Usage

md5

	s :=  hash.NewHashRepo(crypto.MD5).Sum("test")
	fmt.Println(s)

SHA1

	s :=  hash.NewHashRepo(crypto.SHA1).Sum("test")
	fmt.Println(s)

support hash

Interests

Calculate interests

Test file

interests_test

Daily interests

func main() {
	daily, _ := interests.GetInterestRepo(interests.CalcTypeDaily)
	set := &interests.InterestSets{
			RateType:     interests.RateTypeDay,
			InterestRate: 0.1 / 100,
			PayTimes:     30,
			Amount:       1000000,
			StartDate:    "2015-08-31",
		}
	payback, err := daily.CalcPayback(set)
	fmt.Println(err, *payback)
}

AverageCapital

func main() {
	average, _ := interests.GetInterestRepo(interests.CalcTypeAverageCapital)
	set := &interests.InterestSets{
			RateType:     interests.RateTypeDay,
			InterestRate: 0.1 / 100,
			PayTimes:     30,
			Amount:       1000000,
			StartDate:    "2015-08-31",
		}
	payback, err := average.CalcPayback(set)
	fmt.Println(err, *payback)
}

AverageCapitalPlus

func main() {
	plus, _ := interests.GetInterestRepo(interests.CalcTypeAverageCapitalPlus)
	set := &interests.InterestSets{
			RateType:     interests.RateTypeDay,
			InterestRate: 0.1 / 100,
			PayTimes:     30,
			Amount:       1000000,
			StartDate:    "2015-08-31",
		}
	payback, err := plus.CalcPayback(set)
	fmt.Println(err, *payback)
}

Network-worth

Calculate graphs by capacity and cost per unit

Test file

network-worth:spfa

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages