Documentation ¶
Index ¶
- Constants
- Variables
- func ShowUsage(w io.Writer) error
- type CheckResult
- type Cmd
- type CmdName
- type Code
- type Codes
- type Difficulty
- type ExecCmd
- type Format
- type GenerateCmd
- type GetQuestionBody
- type GetQuestionDetailResult
- type GetQuestionResponse
- type GetQuestionResponseData
- type GetQuestionVariables
- type HelpCmd
- type LCOp
- type LeetCode
- func (lc *LeetCode) Check(ctx context.Context, q *Question, id string) (*CheckResult, error)
- func (lc *LeetCode) GetProblems(ctx context.Context) (*ProblemsResult, error)
- func (lc *LeetCode) GetQuestion(ctx context.Context, stat Stat) (*Question, error)
- func (lc *LeetCode) GetQuestionByFrontendID(ctx context.Context, id int) (*Question, error)
- func (lc *LeetCode) GetStats(ctx context.Context) ([]*StatStatusPair, error)
- func (lc *LeetCode) Submit(ctx context.Context, q *Question, ans string) (string, error)
- func (lc *LeetCode) Test(ctx context.Context, q *Question, ans string) (string, error)
- type Level
- type ListCmd
- type PickCmd
- type ProblemsResult
- type QdrData
- type Question
- type SolutionRequest
- type SolutionResult
- type Stat
- type StatStatusPair
- type SubmitRequest
- type SubmitResult
- type TestCmd
Constants ¶
View Source
const ( LIST CmdName = "list" PICK = "pick" GENERATE = "generate" TEST = "test" EXEC = "exec" HELP = "help" )
View Source
const ( Easy Level = 1 Medium = 2 Hard = 3 )
Variables ¶
View Source
var CmdMap = map[CmdName]Cmd{ EXEC: &ExecCmd{}, LIST: &ListCmd{}, GENERATE: &GenerateCmd{}, TEST: &TestCmd{}, PICK: &PickCmd{}, HELP: &HelpCmd{}, }
View Source
var PaidOnlyError = fmt.Errorf("not support premium question for now")
Functions ¶
Types ¶
type CheckResult ¶
type CheckResult struct { StatusCode int `json:"status_code"` Lang string `json:"lang"` CompileError string `json:"compile_error"` FullCompileError string `json:"full_compile_error"` RunSuccess bool `json:"run_success"` StatusRuntime string `json:"status_runtime"` Memory int `json:"memory"` CodeAnswer []string `json:"code_answer"` CodeOutput interface{} `json:"code_output"` // stringのときと[]stringのときがありうる ElapsedTime int `json:"elapsed_time"` TaskFinishTime int64 `json:"task_finish_time"` ExpectedStatusCode int `json:"expected_status_code"` ExpectedLang string `json:"expected_lang"` ExpectedRunSuccess bool `json:"expected_run_success"` ExpectedStatusRuntime string `json:"expected_status_runtime"` ExpectedMemory int `json:"expected_memory"` ExpectedCodeAnswer []string `json:"expected_code_answer"` ExpectedCodeOutput []interface{} `json:"expected_code_output"` ExpectedElapsedTime int `json:"expected_elapsed_time"` ExpectedTaskFinishTime int64 `json:"expected_task_finish_time"` CorrectAnswer bool `json:"correct_answer"` TotalCorrect int `json:"total_correct"` TotalTestcases int `json:"total_testcases"` RuntimePercentile interface{} `json:"runtime_percentile"` StatusMemory string `json:"status_memory"` MemoryPercentile interface{} `json:"memory_percentile"` PrettyLang string `json:"pretty_lang"` SubmissionID string `json:"submission_id"` StatusMsg string `json:"status_msg"` State string `json:"state"` QuestionID string `json:"question_id"` CompareResult string `json:"compare_result"` StdOutput string `json:"std_output"` LastTestcase string `json:"last_testcase"` }
CheckResult is the response from below URL. https://leetcode.com/submissions/detail/${id}/check/
type Code ¶
type Code struct { Text string `json:"text"` Value string `json:"value"` DefaultCode string `json:"defaultCode"` }
Code the struct of leetcode codes.
type Difficulty ¶
type Difficulty struct {
Level Level `json:"level"`
}
type GenerateCmd ¶
type GenerateCmd struct{}
func (*GenerateCmd) MaxArg ¶
func (g *GenerateCmd) MaxArg() int
func (*GenerateCmd) Name ¶
func (c *GenerateCmd) Name() string
func (*GenerateCmd) Usage ¶
func (g *GenerateCmd) Usage() string
type GetQuestionBody ¶
type GetQuestionBody struct { Query string `json:"query"` Variables GetQuestionVariables `json:"variables"` OperationName string `json:"operationName"` }
type GetQuestionDetailResult ¶
type GetQuestionDetailResult struct {
Data QdrData `json:"data"`
}
type GetQuestionResponse ¶
type GetQuestionResponse struct {
Data GetQuestionResponseData `json:"data"`
}
type GetQuestionResponseData ¶
type GetQuestionResponseData struct {
Question *Question `json:"question"`
}
type GetQuestionVariables ¶
type GetQuestionVariables struct {
TitleSlug string `json:"titleSlug"`
}
type LeetCode ¶
type LeetCode struct { BaseURL string // contains filtered or unexported fields }
func NewLeetCode ¶
func (*LeetCode) GetProblems ¶
func (lc *LeetCode) GetProblems(ctx context.Context) (*ProblemsResult, error)
func (*LeetCode) GetQuestion ¶
func (*LeetCode) GetQuestionByFrontendID ¶
func (*LeetCode) GetStats ¶
func (lc *LeetCode) GetStats(ctx context.Context) ([]*StatStatusPair, error)
type ProblemsResult ¶
type ProblemsResult struct { UserName string `json:"user_name"` NumSolved int `json:"num_solved"` NumTotal int `json:"num_total"` AcEasy int `json:"ac_easy"` AcMedium int `json:"ac_medium"` AcHard int `json:"ac_hard"` StatStatusPairs []*StatStatusPair `json:"stat_status_pairs"` FrequencyHigh int `json:"frequency_high"` FrequencyMid int `json:"frequency_mid"` CategorySlug string `json:"category_slug"` }
type Question ¶
type Question struct { Slug string `json:"-"` Referer string `json:"-"` FrontendQuestionID int `json:"-"` QuestionID string `json:"questionId"` Content string `json:"content"` Stats string `json:"stats"` CodeDefinition Codes `json:"codeDefinition"` SampleTestCase string `json:"sampleTestCase"` EnableRunCode bool `json:"enableRunCode"` MetaData string `json:"metaData"` TranslatedContent interface{} `json:"translatedContent"` }
type SolutionRequest ¶
type SolutionRequest struct { Lang string `json:"lang"` // golang QuestionID string `json:"question_id"` TestMode string `json:"test_mode"` // false Name string `json:"name"` DataInput string `json:"data_input"` // ex: "[2,7,11,15]\n9", load from Question.SampleTestCase TypedCode string `json:"typed_code"` // load from file }
SolutionRequest is the parameters for below URL. https://leetcode.com/problems/${title_slug}/interpret_solution/
type SolutionResult ¶
type SolutionResult struct { InterpretID string `json:"interpret_id"` TestCase string `json:"test_case"` }
SolutionResult is the response from below URL. https://leetcode.com/problems/${title_slug}/interpret_solution/
type Stat ¶
type Stat struct { QuestionID int `json:"question_id"` QuestionArticleLive interface{} `json:"question__article__live"` QuestionArticleSlug interface{} `json:"question__article__slug"` QuestionTitle string `json:"question__title"` QuestionTitleSlug string `json:"question__title_slug"` QuestionHide bool `json:"question__hide"` TotalAcs int `json:"total_acs"` TotalSubmitted int `json:"total_submitted"` FrontendQuestionID int `json:"frontend_question_id"` IsNewQuestion bool `json:"is_new_question"` }
type StatStatusPair ¶
type SubmitRequest ¶
type SubmitRequest struct { Lang string `json:"lang"` QuestionID string `json:"question_id"` TestMode string `json:"test_mode"` Name string `json:"name"` JudgeType string `json:"judge_type"` TypedCode string `json:"typed_code"` }
SubmitRequest is the request parameters for below URL. https://leetcode.com/problems/${slug}/submit/
type SubmitResult ¶
type SubmitResult struct {
SubmissionID int `json:"submission_id"`
}
SubmitResult is the response from below URL. https://leetcode.com/problems/${slug}/submit/
Source Files ¶
Click to show internal directories.
Click to hide internal directories.