models

package
v0.0.0-...-f6a6671 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const SudokuLineTypeColumn = "column"
View Source
const SudokuLineTypeRow = "row"

Variables

View Source
var TerminalStyles = styles{
	DefaultStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#eeeeee")),
	PrimaryStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#7777ff")).Bold(true),
	SuccessStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#33ff33")),
	ErrorStyle:   lipgloss.NewStyle().Foreground(lipgloss.Color("#ff3333")),
	BorderStyle:  lipgloss.NewStyle().Foreground(lipgloss.Color("#444444")),
	DebugStyle:   lipgloss.NewStyle().Foreground(lipgloss.Color("#ffd700")),
}

Functions

This section is empty.

Types

type CreateCommandRequest

type CreateCommandRequest struct {
	SudokuConfigRequest
}

type GenericSlice

type GenericSlice[T comparable] []T

func (GenericSlice[T]) All

func (slice GenericSlice[T]) All(predicate func(T) bool) bool

func (GenericSlice[T]) Any

func (slice GenericSlice[T]) Any(predicate func(T) bool) bool

func (GenericSlice[T]) EqualContent

func (slice GenericSlice[T]) EqualContent(comparisionTarget GenericSlice[T]) bool

func (GenericSlice[T]) FirstOrDefault

func (slice GenericSlice[T]) FirstOrDefault(defaultValue T, predicate func(T) bool) T

func (GenericSlice[T]) Intersect

func (slice GenericSlice[T]) Intersect(comparisionTarget GenericSlice[T]) GenericSlice[T]

func (GenericSlice[T]) Where

func (slice GenericSlice[T]) Where(predicate func(T) bool) GenericSlice[T]

type PromptSelectOption

type PromptSelectOption struct {
	Label string
	Value interface{}
}

type Settings

type Settings struct {
	MinimumLayoutSizeInclusive       int8
	MaximumLayoutSizeInclusive       int8
	DefaultLayoutSize                int8
	MinimumBoxSizeInclusive          int8
	MaximumBoxSizeInclusive          int8
	DefaultBoxSize                   int8
	SudokuPrintoutValuePaddingLength int8
	UseDebugPrints                   bool
	SilentConsolePrints              bool
	SudokuBinaryEncoderVersion       uint16
}

type SolveCommandRequest

type SolveCommandRequest struct {
	SudokuConfigRequest
	InputJsonFile *string
	OutputFile    *string
}

type SubSudoku

type SubSudoku struct {
	Id                    guid.UUID
	Boxes                 GenericSlice[*SudokuBox]
	TopLeftBoxRowIndex    int8
	TopLeftBoxColumnIndex int8
	ChildLines            GenericSlice[*SudokuLine]
}

type Sudoku

type Sudoku struct {
	BoxSize    int8
	Layout     SudokuLayout
	Boxes      GenericSlice[*SudokuBox]
	SubSudokus GenericSlice[*SubSudoku]
	Result     SudokuResultType
}

func (*Sudoku) ToSudokuDto

func (sudoku *Sudoku) ToSudokuDto() *SudokuDTO

ToSudoku converts internal sudoku object to DTO object. Suitable for serialization to json

type SudokuBox

type SudokuBox struct {
	Id           guid.UUID
	Disabled     bool
	IndexRow     int8
	IndexColumn  int8
	Cells        GenericSlice[*SudokuCell]
	ViolatesRule bool
}

type SudokuBoxDTO

type SudokuBoxDTO struct {
	Disabled    bool                         `json:"disabled"`
	IndexRow    int8                         `json:"indexRow"`
	IndexColumn int8                         `json:"indexColumn"`
	Cells       GenericSlice[*SudokuCellDTO] `json:"cells"`
}

type SudokuCell

type SudokuCell struct {
	Id               guid.UUID
	Value            *int
	IsInputValue     bool
	PotentialValues  *GenericSlice[int]
	IndexRowInBox    int8
	IndexColumnInBox int8
	Box              *SudokuBox
	MemberOfLines    GenericSlice[*SudokuLine]
}

func (*SudokuCell) HasViolationError

func (cell *SudokuCell) HasViolationError() bool

type SudokuCellDTO

type SudokuCellDTO struct {
	Value            *int `json:"value"`
	IndexRowInBox    int8 `json:"indexRowInBox"`
	IndexColumnInBox int8 `json:"indexColumnInBox"`
}

type SudokuConfigRequest

type SudokuConfigRequest struct {
	BoxSize      *int8
	LayoutWidth  *int8
	LayoutHeight *int8
	Overwrite    bool
}

func (*SudokuConfigRequest) AsConfigRequest

func (r *SudokuConfigRequest) AsConfigRequest() *SudokuConfigRequest

type SudokuDTO

type SudokuDTO struct {
	BoxSize int8                        `json:"boxSize"`
	Layout  SudokuLayoutDTO             `json:"layout"`
	Boxes   GenericSlice[*SudokuBoxDTO] `json:"boxes"`
}

func (*SudokuDTO) ToSudoku

func (sudokuDto *SudokuDTO) ToSudoku() *Sudoku

ToSudoku converts raw sudoku DTO object to internally managed object representing sudoku with all dependencies and computed data.

type SudokuLayout

type SudokuLayout struct {
	Width  int8
	Height int8
}

type SudokuLayoutDTO

type SudokuLayoutDTO struct {
	Width  int8 `json:"width"`
	Height int8 `json:"height"`
}

type SudokuLine

type SudokuLine struct {
	Cells        GenericSlice[*SudokuCell]
	LineType     string
	ViolatesRule bool
	SubsudokuId  guid.UUID
}

type SudokuResultType

type SudokuResultType int8
const (
	Unspecified         SudokuResultType = 0
	SuccessfullSolution SudokuResultType = 1
	Failure             SudokuResultType = 2
	InvalidGuess        SudokuResultType = 3
	UnsolvableSudoku    SudokuResultType = 4
)

type SudokuValueGuess

type SudokuValueGuess struct {
	GuessedValue            int
	GuessedCell             *SudokuCell
	SubsudokuId             guid.UUID
	PotentialValuesSnapshot map[guid.UUID]*[]int
}

Jump to

Keyboard shortcuts

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