leetcode

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Accepted            Status = 10
	WrongAnswer                = 11
	MemoryLimitExceeded        = 12
	OutputLimitExceeded        = 13
	TimeLimitExceeded          = 14
	RuntimeError               = 15
	InternalError              = 16
	CompileError               = 20
	UnknownError               = 21
	Unknown
)
View Source
const (
	Easy   DifficultyFilter = "EASY"
	Medium                  = "MEDIUM"
	Hard                    = "HARD"
)
View Source
const (
	Todo      StatusFilter = "NOT_SOLVED"
	Solved                 = "AC"
	Attempted              = "TRIED"
)

Variables

This section is empty.

Functions

func LocalizeLanguage

func LocalizeLanguage(lang provider.Lang) (string, error)

Types

type CheckResponse

type CheckResponse struct {
	StatusCode        Status  `json:"status_code"`
	Lang              string  `json:"lang"`
	RunSuccess        bool    `json:"run_success"`
	StatusRuntime     string  `json:"status_runtime"`
	CompileError      string  `json:"compile_error"`
	FullCompileError  string  `json:"full_compile_error"`
	RuntimeError      string  `json:"runtime_error"`
	FullRuntimeError  string  `json:"full_runtime_error"`
	Input             string  `json:"input"`
	InputFormatted    string  `json:"input_formatted"`
	Memory            int64   `json:"memory"`
	QuestionId        string  `json:"question_id"`
	ElapsedTime       uint64  `json:"elapsed_time"`
	CompareResult     string  `json:"compare_result"`
	CodeOutput        string  `json:"code_output"`
	StdOutput         string  `json:"std_output"`
	LastTestCase      string  `json:"last_testcase"`
	ExpectedOutput    string  `json:"expected_output"`
	TaskFinishTime    uint64  `json:"task_finish_time"`
	TotalCorrect      uint64  `json:"total_correct"`
	TotalTestCases    uint64  `json:"total_testcases"`
	RuntimePercentile float64 `json:"runtime_percentile"`
	StatusMemory      string  `json:"status_memory"`
	MemoryPercentile  float64 `json:"memory_percentile"`
	PrettyLang        string  `json:"pretty_lang"`
	SubmissionId      string  `json:"submission_id"`
	StatusMsg         string  `json:"status_msg"`
	State             State   `json:"state"`
}

func (*CheckResponse) ErrorReport

func (res *CheckResponse) ErrorReport() *provider.ErrorReport

func (*CheckResponse) HasSucceeded

func (res *CheckResponse) HasSucceeded() bool

func (*CheckResponse) Identify

func (res *CheckResponse) Identify() string

func (*CheckResponse) Statistics

func (res *CheckResponse) Statistics() provider.SubmissionStatistics

type Client

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

func NewClient

func NewClient(base *url.URL) *Client

func (*Client) Configure

func (client *Client) Configure(config provider.BackendConfig) error

func (*Client) FindNextChallenge

func (client *Client) FindNextChallenge(filters provider.Filters) (provider.Filters, error)

func (*Client) GetChallenge

func (client *Client) GetChallenge(filters provider.Filters) (provider.Challenge, error)

func (*Client) GetQuestionData

func (client *Client) GetQuestionData(titleSlug string) (*QuestionData, error)

func (*Client) GetRandomQuestionSlug

func (client *Client) GetRandomQuestionSlug(difficulty DifficultyFilter, status StatusFilter, tags []string, categorySlug string) (string, error)

func (*Client) IsSignedIn

func (client *Client) IsSignedIn() (bool, error)

func (*Client) Submit

func (client *Client) Submit(filters provider.Filters, lang provider.Lang, code string) (provider.SubmissionReport, error)

func (*Client) SubmitCode

func (client *Client) SubmitCode(questionId string, slug string, lang string, code string) (*SubmitResponse, error)

func (*Client) WaitUntilCompleteOrTimeOut

func (client *Client) WaitUntilCompleteOrTimeOut(submissionId int64, timeOut time.Duration) (*CheckResponse, error)

type CodeSnippet

type CodeSnippet struct {
	Lang     string `json:"lang"`
	LangSlug string `json:"langSlug"`
	Code     string `json:"code"`
}

type DifficultyFilter

type DifficultyFilter string

func ParseDifficulty

func ParseDifficulty(s string) (*DifficultyFilter, error)

type Filters

type Filters struct {
	Difficulty DifficultyFilter `json:"difficulty,omitempty"`
	Status     StatusFilter     `json:"status,omitempty"`
	Tags       []string         `json:"tags,omitempty"`
}

type QuestionData

type QuestionData struct {
	QuestionId   string        `json:"questionId"`
	Title        string        `json:"title"`
	TitleSlug    string        `json:"titleSlug"`
	Difficulty   string        `json:"difficulty"`
	Likes        uint64        `json:"likes"`
	Dislikes     uint64        `json:"dislikes"`
	Content      string        `json:"content"`
	CodeSnippets []CodeSnippet `json:"codeSnippets"`
}

func (*QuestionData) Files

func (data *QuestionData) Files() (map[string]string, error)

func (*QuestionData) Identify

func (data *QuestionData) Identify() provider.Filters

func (*QuestionData) Prompt

func (data *QuestionData) Prompt() string

func (*QuestionData) Snippet

func (data *QuestionData) Snippet(lang provider.Lang) (string, error)

type State

type State string
const (
	Success State = "SUCCESS"
	Pending       = "PENDING"
)

type Status

type Status int16

type StatusFilter

type StatusFilter string

func ParseStatus

func ParseStatus(s string) (*StatusFilter, error)

type SubmitRequest

type SubmitRequest struct {
	Lang       string `json:"lang"`
	QuestionId string `json:"question_id"`
	TypedCode  string `json:"typed_code"`
}

type SubmitResponse

type SubmitResponse struct {
	SubmissionId int64 `json:"submission_id"`
}

Jump to

Keyboard shortcuts

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