pbinfo

package
v0.0.0-...-3c72c70 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// The HTTP client to use. Defaults to http.DefaultClient.
	Client *http.Client
	// contains filtered or unexported fields
}

The Client is used to retrieve data from the PbInfo platform.

func (*Client) FindProblemByID

func (c *Client) FindProblemByID(ctx context.Context, id int) (*Problem, error)

FindProblemByID returns the information associated with the problem identified by the given ID. It returns an error if the problem does not exist, a network error occurs etc.

func (*Client) GetProblemTestCases

func (c *Client) GetProblemTestCases(ctx context.Context, problemID int) ([]TestCase, error)

GetProblemTestCases returns the test cases for the problem identified by the given ID. It firstly tries to retrieve all the test cases, if they are available, otherwise it retrieves only the example test cases. It returns an error if the problem does not exist, a network error occurs etc.

type Problem

type Problem struct {
	// The ID of the problem.
	ID int
	// The name of the problem.
	Name string
	// The person that published this problem.
	Publisher string
	// The grade the problem is targeted at. If 0, grade is unknown.
	Grade int
	// The input file. Is empty if the input is from STDIN.
	Input string
	// The output file. It is empty if the output is to STDOUT.
	Output string
	// The maximum execution time of the solution. If 0, no time limit is given.
	MaxTime time.Duration
	// The maximum amount of both stack and heap memory used by the solution, in bytes.
	// If 0, no memory limit is given.
	MaxMemoryBytes int64
	// The maximum amount of stack memory used by the solution, in bytes.
	// If 0, no memory limit is given.
	MaxStackBytes int64
	// The source of the problem: the place where it was taken from. If empty, source is unknown.
	Source string
	// The authors of the problem. If empty/nil, the author is considered the poster.
	Authors []string
	// The difficulty of the problem.
	Difficulty ProblemDifficulty
	// The score of the latest uploaded solution. It is nil if no solution was uploaded before.
	Score *int
}

Problem represents a single PbInfo problem.

func (*Problem) InputFromStdin

func (p *Problem) InputFromStdin() bool

InputFromStdin indicates whether the problem input should be read from standard input or not. If this is not true, Problem.Input indicates the expected input filename.

func (*Problem) OutputToStdout

func (p *Problem) OutputToStdout() bool

OutputToStdout indicates whether the problem output should be written to standard output or not. If this is not true, Problem.Output indicates the expected output filename.

func (*Problem) ReadableMaxMemory

func (p *Problem) ReadableMaxMemory() string

ReadableMaxMemory returns the memory limit of the solution in a human-readable format.

func (*Problem) ReadableMaxStack

func (p *Problem) ReadableMaxStack() string

ReadableMaxStack returns the stack memory limit of the solution in a human-readable format.

type ProblemDifficulty

type ProblemDifficulty int

ProblemDifficulty represents the difficulty of a problem.

const (
	Unknown ProblemDifficulty = iota
	Easy
	Medium
	Difficult
	Contest
)

func ParseProblemDifficulty

func ParseProblemDifficulty(input string) ProblemDifficulty

ParseProblemDifficulty tries to determine the difficulty of a problem from the given string. It normalizes the input by converting it to lowercase and converting letters with diacritics to their closest ASCII equivalent, and then it compares the result with certain predefined values associated with difficulty levels. If no matching value is found, the Unknown difficulty is returned.

func (ProblemDifficulty) String

func (p ProblemDifficulty) String() string

type TestCase

type TestCase struct {
	Input     []byte
	Output    []byte
	IsExample bool
	Score     int
}

TestCase holds the input and the expected output for a single test case of a problem.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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