algorithm

package module
v0.0.0-...-4806b60 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 0 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	GraphFrom string `json:"graph_from"`
	GraphTo   string `json:"graph_to"`

	Capacity    float64 `json:"capacity"`
	CostPerUnit int64   `json:"cost_per_unit"`
}

type Graphs

type Graphs struct {
	Graphs []Graph `json:"graphs"`

	Cost int64 `json:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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