simulator

package
v0.0.0-...-5c60df6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2016 License: MIT Imports: 1 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircleOfDeath

type CircleOfDeath struct {
	// contains filtered or unexported fields
}

CircleOfDeath represents a circle in josephus problem. This object is responsible to run the simulation, and return the result.

func (*CircleOfDeath) Execute

func (c *CircleOfDeath) Execute() Result

Execute executes the simulation It returns Result struct instance.

func (*CircleOfDeath) Init

func (c *CircleOfDeath) Init(numberOfPeople uint64, stepPerKill int)

Init initializes the CircleOfDeath. It takes two argument, first is the number of people in the circle Second is steps per kill.

type Person

type Person struct {
	// contains filtered or unexported fields
}

Person represents individual person in the circle

func (*Person) GetPosition

func (p *Person) GetPosition() int

GetPosition gets the position of the Person

func (*Person) Init

func (p *Person) Init(position int)

Init initializes the person.

func (*Person) IsAlive

func (p *Person) IsAlive() bool

IsAlive indicates whether this person is alive or not

func (*Person) Kill

func (p *Person) Kill()

Kill changes state of person from alive to dead

type Result

type Result struct {
	LastAlive    int
	KillingOrder []int
}

Result is used to indicate the result of the simulation. LastAlive referes to the position of the person, who will be lastalive. KillingOrder referes to the position, in which the killing was performed.

Jump to

Keyboard shortcuts

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