Skip to content

Commit

Permalink
Fix CPython.uz sample cases parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Dec 8, 2023
1 parent e31b7de commit 4be9e2a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
- Fixed the parsing of Kattis problems and contests
- Fixed the parsing of sample cases on CPython.uz containing multiple lines

## [2.48.0](https://github.com/jmerle/competitive-companion/releases/tag/2.48.0) (2023-12-07)
- Added a contest parser for TLX (thanks [@user202729](https://github.com/user202729))
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/problem/CPythonUZProblemParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CPythonUZProblemParser extends Parser {

elem.querySelectorAll('.sample-test').forEach(tableElem => {
const blocks = tableElem.querySelectorAll('pre');
task.addTest(blocks[0].textContent, blocks[1].textContent);
task.addTest(blocks[0].innerHTML, blocks[1].innerHTML);
});

return task.build();
Expand Down
4 changes: 4 additions & 0 deletions tests/before-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const beforeFunctions: { [name: string]: (page: Page) => Promise<void> }
await page.waitForSelector('h1');
},

async beforeCPythonUZ(page: Page): Promise<void> {
await page.waitForSelector('h2.text-center, h2.content-header-title');
},

async beforeECNU(page: Page): Promise<void> {
await page.waitForSelector('.property > p > strong');
},
Expand Down
16 changes: 8 additions & 8 deletions tests/data/cpython-uz/contest/normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/A",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "4\n2\n",
Expand Down Expand Up @@ -39,7 +39,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/B",
"interactive": false,
"memoryLimit": 512,
"timeLimit": 2000,
"timeLimit": 1000,
"tests": [
{
"input": "4\n1 2 3 4\n",
Expand All @@ -66,7 +66,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/C",
"interactive": false,
"memoryLimit": 512,
"timeLimit": 2000,
"timeLimit": 1000,
"tests": [
{
"input": "2\n2\n",
Expand Down Expand Up @@ -105,7 +105,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/D",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "10\n21 10 6 82 120 16 3 8 2 65\n",
Expand All @@ -132,7 +132,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/E",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "2022\n7\n",
Expand Down Expand Up @@ -167,7 +167,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/F",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "9\nAsilbek Davlatbek\nodmin admin\nadmin Asilbek\nadmin\nadmin odmin\nDavlatbek Asilbek\nAsilbek Davlatbek admin\nadmin odmin Davlatbek\nAsilbek Davlatbek\n",
Expand All @@ -194,7 +194,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/G",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "5\n",
Expand Down Expand Up @@ -229,7 +229,7 @@
"url": "https://cpython.uz/competitions/contests/contest/297/problem/H",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "4 2\n1 2\n3 4\n",
Expand Down
7 changes: 4 additions & 3 deletions tests/data/cpython-uz/problem/contest.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"url": "https://cpython.uz/competitions/contests/contest/297/problem/A",
"parser": "CPythonUZProblemParser",
"before": "beforeCPythonUZ",
"result": {
"name": "A. One Line | Divisible",
"group": "CPython.uz - One Line #8 | Feat. Less Code",
"url": "https://cpython.uz/competitions/contests/contest/297/problem/A",
"interactive": false,
"memoryLimit": 256,
"timeLimit": 1000,
"timeLimit": 500,
"tests": [
{
"input": "42\n",
"input": "4\n2\n",
"output": "Yes\n"
},
{
"input": "24\n",
"input": "2\n4\n",
"output": "No\n"
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/data/cpython-uz/problem/duel.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"url": "https://cpython.uz/practice/duels/duel/12",
"parser": "CPythonUZProblemParser",
"before": "beforeCPythonUZ",
"result": {
"name": "A. Ifoda",
"group": "CPython.uz",
"url": "https://cpython.uz/practice/duels/duel/12",
"interactive": false,
"memoryLimit": 512,
"timeLimit": 2000,
"timeLimit": 1000,
"tests": [],
"testType": "single",
"input": {
Expand Down
5 changes: 3 additions & 2 deletions tests/data/cpython-uz/problem/normal.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"url": "https://cpython.uz/practice/problems/problem/1",
"parser": "CPythonUZProblemParser",
"before": "beforeCPythonUZ",
"result": {
"name": "The sum of two numbers",
"group": "CPython.uz",
Expand All @@ -10,11 +11,11 @@
"timeLimit": 1000,
"tests": [
{
"input": "2 2\n",
"input": "2\n2\n",
"output": "4\n"
},
{
"input": "5 10\n",
"input": "5\n10\n",
"output": "15\n"
}
],
Expand Down

0 comments on commit 4be9e2a

Please sign in to comment.