einsteinriddle

package module
v0.0.0-...-bab9360 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: MIT Imports: 6 Imported by: 0

README

einstein-riddle-generator

🎲 Einstein Riddle Generator

GoDoc

Check out the demo on Appspot !

Install

$ go get github.com/moul/einstein-riddle-generator/...

Example

$ einstein-riddle
Riddle
------
- job:cop == pet:shark
- room:kitchen == nationality:scottish
- house-color:red == pet:beaver
- nationality:spannish == house-color:pink
- job:scientist == room:bedroom
- room:restroom == job:designer
- job:teacher == pet:poney
- pet:bird is direct on the right of job:architect
- nationality:american == room:bathroom
- nationality:french == room:garden
- house-color:yellow is on the left of nationality:english
- house-color:blue is in the middle
- room:bedroom == nationality:english
- pet:beaver is on the right of room:bathroom
- job:architect is direct on the right of nationality:french
- job:cop is on the far left
- pet:shark is on the far left
- nationality:american is on the far left

- where is pet:snake ?
- where is house-color:magenta ?

Answer
------
              1             2            3              4             5
room          2: bathroom   1: garden    1: kitchen     1: restroom   2: bedroom
job           2: cop        1: teacher   2: architect   1: designer   1: scientist
pet           2: shark      1: poney     0: snake       1: bird       2: beaver
house-color   0: magenta    1: yellow    1: blue        1: pink       1: red
nationality   2: american   2: french    1: scottish    1: spannish   2: english

License

MIT

Documentation

Index

Constants

View Source
const (
	KindNationality = iota
	KindHouseColor
	KindPet
	KindJob
	KindBeverage
	KindWeapon
	KindTransport
	KindRoom
)

Variables

View Source
var BaseGenerator map[int]ItemList
View Source
var KindName map[int]string

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Options Options

	Vector  []int
	Pickeds []PickedGroup

	Items map[int]ItemList
	Kinds []int
}

func NewGenerator

func NewGenerator(options Options) *Generator

func (*Generator) At

func (g *Generator) At(idx int) Item

func (*Generator) EOF

func (g *Generator) EOF() bool

func (*Generator) GroupString

func (g *Generator) GroupString(group PickedGroup) string

func (*Generator) Length

func (g *Generator) Length() int

func (*Generator) Missings

func (g *Generator) Missings() []Item

func (*Generator) PickAvailableGroup

func (g *Generator) PickAvailableGroup(maxLevel int) []int

func (*Generator) PickItemAtExtremity

func (g *Generator) PickItemAtExtremity(targetCounter int) []int

func (*Generator) PickSamePersonGroup

func (g *Generator) PickSamePersonGroup(maxLevel int) []int

func (*Generator) Shazam

func (g *Generator) Shazam() error

func (*Generator) Show

func (g *Generator) Show()

type Item

type Item struct {
	Kind   int
	Value  string
	Idx    int
	Person int
}

func (*Item) Name

func (i *Item) Name() string

type ItemList

type ItemList []string

func (*ItemList) Shuffle

func (il *ItemList) Shuffle()

type Options

type Options struct {
	Size             int
	Categories       int
	GroupSize        int
	Secrets          int
	Seed             int64
	SamePersonGroups int
}

func (*Options) ApplyDefaults

func (o *Options) ApplyDefaults()

type PickedGroup

type PickedGroup []int

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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