Documentation
¶
Overview ¶
Package flipper contains my personal solution to the 'Revenge of the Pancakes' coding challenge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoEverything ¶
func DoEverything() error
DoEverything is just an exported function that creates a default flipper, reads the input, solves, and outputs.
Types ¶
type Flipper ¶
type Flipper struct {
// contains filtered or unexported fields
}
Flipper is the solver for the pancake problem. Handles the input and output and solves.
func NewFlipper ¶
NewFlipper creates a new flipper struct with buffered io using the passed in input and output sinks.
func (*Flipper) ReadProblem ¶
ReadProblem reads the problem from the io.Reader input and stores it in the struct members.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a stack of pancakes and has some ease of use methods.
func (*Stack) Equals ¶
Equals is just a helper method for checking the state of those yummy pancakes to see if their current state is equal to the passed in slice.
func (*Stack) EqualsString ¶
EqualsString accepts a string and passes to Equals.
func (*Stack) Flip ¶
Flip flips the first n pancakes in-place in the slice of bools and increments the internal flip counter. n <= 0 is a no-op and does not increment the flip count.
func (*Stack) LowestFlip ¶
LowestFlip finds the first from the bottom that needs to be flipped. Returns how many to flip to fix it for directly passing into Flip