Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for gym problems #513

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ export const submitToCodeForces = async () => {

/** 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+)/,
];

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

return problemName;
return '';
};
Loading