Skip to content

Commit

Permalink
Add support for gym problems
Browse files Browse the repository at this point in the history
  • Loading branch information
nullchilly committed Dec 20, 2024
1 parent 5d0fed3 commit c708f8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@vscode/extension-telemetry": "^0.9.0",
"python-shell": "^5.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-textarea-autosize": "^8.5.3",
"@vscode/extension-telemetry": "^0.9.0"
"react-textarea-autosize": "^8.5.3"
},
"repository": {
"type": "git",
Expand Down
24 changes: 13 additions & 11 deletions src/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,20 @@ export const submitToCodeForces = async () => {
});
};

/** Get the problem name ( like 144C ) for a given Codeforces URL string. */
/** Get the problem name (like 144C) for a given Codeforces URL string. */
export const getProblemName = (problemUrl: string): string => {
const parts = problemUrl.split('/');
let problemName: string;

if (parts.find((x) => x == 'contest')) {
// Url is like https://codeforces.com/contest/1398/problem/C
problemName = parts[parts.length - 3] + parts[parts.length - 1];
} else {
// Url is like https://codeforces.com/problemset/problem/1344/F
problemName = parts[parts.length - 2] + parts[parts.length - 1];
const regexPatterns = [
/\/contest\/(\d+)\/problem\/(\w+)/,
/\/problemset\/problem\/(\d+)\/(\w+)/,
/\/gym\/(\d+)\/problem\/(\w+)/

Check failure on line 94 in src/submit.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Insert `,`
];

for (const regex of regexPatterns) {
const match = problemUrl.match(regex);
if (match) {
return match[1] + match[2];
}
}

return problemName;
return '';
};

0 comments on commit c708f8d

Please sign in to comment.