MCPcopy Create free account
hub / github.com/EndlessCheng/codeforces-go / parseCodeforcesProblemURL

Function parseCodeforcesProblemURL

copypasta/template/helper.go:36–48  ·  view source on GitHub ↗

https://codeforces.com/problemset/problem/1293/C https://codeforces.com/contest/1353/problem/A https://codeforces.com/gym/102253/problem/C

(urlStr string)

Source from the content-addressed store, hash-verified

34// https://codeforces.com/contest/1353/problem/A
35// https://codeforces.com/gym/102253/problem/C
36func parseCodeforcesProblemURL(urlStr string) (contestID, problemID string, isGYM bool) {
37 sp := strings.Split(urlStr, "/")
38 switch {
39 case strings.Contains(urlStr, "/problemset/problem/"):
40 return sp[len(sp)-2], sp[len(sp)-1], false
41 case strings.Contains(urlStr, "/contest/"):
42 return sp[len(sp)-3], sp[len(sp)-1], false
43 case strings.Contains(urlStr, "/gym/"):
44 return sp[len(sp)-3], sp[len(sp)-1], true
45 default:
46 panic("invalid URL")
47 }
48}
49
50func genDirName(contestID string) string {
51 cid, err := strconv.Atoi(contestID)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected