Skip to content

Commit 392918b

Browse files
committed
Add support for gym problems
1 parent 5d0fed3 commit 392918b

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

package.json

+2-24
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,6 @@
149149
],
150150
"description": "C++ compiler's argument that specifies the output files."
151151
},
152-
"cph.language.csharp.Args": {
153-
"title": "Compilation flags for .cs files",
154-
"type": "string",
155-
"default": "",
156-
"description": "Space seperated additional flags passed to dotnet while compiling your file."
157-
},
158-
"cph.language.csharp.SubmissionCompiler": {
159-
"type": "string",
160-
"default": "C# 8, .NET Core 3.1",
161-
"enum": [
162-
"C# 8, .NET Core 3.1",
163-
"C# 10, .NET SDK 6.0",
164-
"C# Mono 6.8"
165-
],
166-
"description": "The compiler chosen in the drop down during Codeforces submission for C#"
167-
},
168-
"cph.language.csharp.Command": {
169-
"type": "string",
170-
"default": "dotnet",
171-
"description": "Command used to compile .cs files. 'dotnet' for C# .NET, 'mcs' for C# Mono"
172-
},
173152
"cph.language.python.Args": {
174153
"title": "Compilation flags for Python",
175154
"type": "string",
@@ -326,14 +305,13 @@
326305
"rust",
327306
"js",
328307
"java",
329-
"ruby",
330-
"csharp"
308+
"ruby"
331309
],
332310
"description": "The default language for problems imported via Competitive Companion (None will give option to select language on importing problem every time)"
333311
},
334312
"cph.general.menuChoices": {
335313
"type": "string",
336-
"default": "cpp java js python c rust ruby csharp",
314+
"default": "cpp java js python c rust ruby",
337315
"description": "Space separated languages, in top to bottom order, shown in menu when a problem is imported via Competitive Companion. Example 'java python' would show java on top, followed by python."
338316
},
339317
"cph.general.useShortCodeForcesName": {

src/submit.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,20 @@ export const submitToCodeForces = async () => {
8686
});
8787
};
8888

89-
/** Get the problem name ( like 144C ) for a given Codeforces URL string. */
89+
/** Get the problem name (like 144C) for a given Codeforces URL string. */
9090
export const getProblemName = (problemUrl: string): string => {
91-
const parts = problemUrl.split('/');
92-
let problemName: string;
93-
94-
if (parts.find((x) => x == 'contest')) {
95-
// Url is like https://codeforces.com/contest/1398/problem/C
96-
problemName = parts[parts.length - 3] + parts[parts.length - 1];
97-
} else {
98-
// Url is like https://codeforces.com/problemset/problem/1344/F
99-
problemName = parts[parts.length - 2] + parts[parts.length - 1];
91+
const regexPatterns = [
92+
/\/contest\/(\d+)\/problem\/(\w+)/,
93+
/\/problemset\/problem\/(\d+)\/(\w+)/,
94+
/\/gym\/(\d+)\/problem\/(\w+)/,
95+
];
96+
97+
for (const regex of regexPatterns) {
98+
const match = problemUrl.match(regex);
99+
if (match) {
100+
return match[1] + match[2];
101+
}
100102
}
101103

102-
return problemName;
104+
return '';
103105
};

0 commit comments

Comments
 (0)