leet

package
v0.0.0-...-9b92ec5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const UA = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36`

Variables

This section is empty.

Functions

func Copy

func Copy(srcFile, dstFile string) error

func CopyDirectory

func CopyDirectory(scrDir, dest string) error

func CopyFile

func CopyFile(dstName, srcName string) (written int64, err error)
func CopySymLink(source, dest string) error

func CreateIfNotExists

func CreateIfNotExists(dir string, perm os.FileMode) error

func CustomerCode

func CustomerCode(code string) string

返回用户自定义代码部分

func CustomerCodeLine

func CustomerCodeLine(code string) int

返回用户代码起始行

func CustomerCodeLineByFile

func CustomerCodeLineByFile(dir string) int

func Exists

func Exists(filePath string) bool

func GetAllQuestionTitleSlug

func GetAllQuestionTitleSlug() (res []string)

func GetQuestionInfo

func GetQuestionInfo(titleSlug string) (info store.Store)

func GetQuestionInfoByID

func GetQuestionInfoByID(questionID string) (info store.Store)

func GolangClear

func GolangClear(dir string) (err error)

func InfoPrint

func InfoPrint(info store.Store, withDetail bool)

func Parse

func Parse(param string) string

Parse ... param: 222 param: https://leetcode-cn.com/problems/k-th-symbol-in-grammar param: https://leetcode-cn.com/problems/k-th-symbol-in-grammar/solution/ param: leetcode-cn.com/problems/k-th-symbol-in-grammar

func ParseFromURL

func ParseFromURL(param string) string

ParseFromURL param: https://leetcode-cn.com/problems/k-th-symbol-in-grammar param: https://leetcode-cn.com/problems/k-th-symbol-in-grammar/solution/ param: leetcode-cn.com/problems/k-th-symbol-in-grammar

func ProblemID2name

func ProblemID2name(id string) (stats store.QuestionStats, err error)

ProblemID2name return problem info

func Timeout

func Timeout(duration time.Duration, fn func(ctx context.Context, cancel context.CancelFunc)) (ok bool)

func UpdateQuestionInfo

func UpdateQuestionInfo(que Question, local Localization)

Types

type AllProblemsResult

type AllProblemsResult 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 []struct {
		Stat       store.QuestionStats `json:"stat"`
		Status     interface{}         `json:"status"`
		Difficulty struct {
			Level int `json:"level"`
		} `json:"difficulty"`
		PaidOnly  bool `json:"paid_only"`
		IsFavor   bool `json:"is_favor"`
		Frequency int  `json:"frequency"`
		Progress  int  `json:"progress"`
	} `json:"stat_status_pairs"`
	FrequencyHigh int    `json:"frequency_high"`
	FrequencyMid  int    `json:"frequency_mid"`
	CategorySlug  string `json:"category_slug"`
}

type BackupClear

type BackupClear struct {
	Dir      string `json:"dir"`
	Language string `json:"language"`
}

func (BackupClear) Backup

func (th BackupClear) Backup(override bool) error

func (BackupClear) Clear

func (th BackupClear) Clear() (err error)

type CodeSnippet

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

type Localization

type Localization struct {
	TitleSlug      string        `json:"title_slug"`
	QuestionID     string        `json:"question_id"`
	Title          string        `json:"title"`
	Difficulty     string        `json:"difficulty"`
	Question       string        `json:"question"`
	CodeSnippets   []CodeSnippet `json:"code_snippets"`
	SampleTestCase string        `json:"sample_test_case"`

	SaveDirs []string `json:"save_dirs"`
}

func (*Localization) Save

func (th *Localization) Save(override bool)

type Question

type Question struct {
	QuestionID            string        `json:"questionId"`
	QuestionFrontendID    string        `json:"questionFrontendId"`
	BoundTopicID          int           `json:"boundTopicId"`
	Title                 string        `json:"title"`
	TitleSlug             string        `json:"titleSlug"`
	Content               string        `json:"content"`
	TranslatedTitle       string        `json:"translatedTitle"`
	TranslatedContent     string        `json:"translatedContent"`
	IsPaidOnly            bool          `json:"isPaidOnly"`
	Difficulty            string        `json:"difficulty"`
	Likes                 int           `json:"likes"`
	Dislikes              int           `json:"dislikes"`
	IsLiked               interface{}   `json:"isLiked"`
	SimilarQuestions      string        `json:"similarQuestions"`
	Contributors          []interface{} `json:"contributors"`
	LangToValidPlayground string        `json:"langToValidPlayground"`
	TopicTags             []struct {
		Name           string `json:"name"`
		Slug           string `json:"slug"`
		TranslatedName string `json:"translatedName"`
		Typename       string `json:"__typename"`
	} `json:"topicTags"`
	CompanyTagStats   interface{}   `json:"companyTagStats"`
	CodeSnippets      []CodeSnippet `json:"codeSnippets"`
	Stats             string        `json:"stats"`
	Hints             []interface{} `json:"hints"`
	Solution          interface{}   `json:"solution"`
	Status            interface{}   `json:"status"`
	SampleTestCase    string        `json:"sampleTestCase"`
	MetaData          string        `json:"metaData"`
	JudgerAvailable   bool          `json:"judgerAvailable"`
	JudgeType         string        `json:"judgeType"`
	MysqlSchemas      []interface{} `json:"mysqlSchemas"`
	EnableRunCode     bool          `json:"enableRunCode"`
	EnvInfo           string        `json:"envInfo"`
	Book              interface{}   `json:"book"`
	IsSubscribed      bool          `json:"isSubscribed"`
	IsDailyQuestion   bool          `json:"isDailyQuestion"`
	DailyRecordStatus interface{}   `json:"dailyRecordStatus"`
	EditorType        string        `json:"editorType"`
	UgcQuestionID     interface{}   `json:"ugcQuestionId"`
	Style             string        `json:"style"`
	Typename          string        `json:"__typename"`
}

type QuestionDetail

type QuestionDetail struct {
	Data struct {
		Question Question `json:"question"`
	} `json:"data"`
}

func Fetch

func Fetch(title string) (qd QuestionDetail, err error)

func (*QuestionDetail) Download

func (th *QuestionDetail) Download(override bool)

type SaveOption

type SaveOption struct {
	SaveDir, Title, TitleSlug,
	Difficulty, Question, CodeSnippet,
	SampleTestCase, Language string
}

func (SaveOption) SaveQuestion

func (th SaveOption) SaveQuestion() (err error)

type TestLog

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

func NewTestLog

func NewTestLog(length int) *TestLog

func (*TestLog) Fail

func (th *TestLog) Fail(index, name, reason interface{})

func (*TestLog) Pass

func (th *TestLog) Pass(index, name interface{})

func (*TestLog) Render

func (th *TestLog) Render()

func (*TestLog) SetMaxLength

func (th *TestLog) SetMaxLength(length int)

Jump to

Keyboard shortcuts

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