From 4be9e2ae24fd360243517b9d75c276b68cf0ecab Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Fri, 8 Dec 2023 06:50:27 +0100 Subject: [PATCH] Fix CPython.uz sample cases parsing --- CHANGELOG.md | 1 + src/parsers/problem/CPythonUZProblemParser.ts | 2 +- tests/before-functions.ts | 4 ++++ tests/data/cpython-uz/contest/normal.json | 16 ++++++++-------- tests/data/cpython-uz/problem/contest.json | 7 ++++--- tests/data/cpython-uz/problem/duel.json | 3 ++- tests/data/cpython-uz/problem/normal.json | 5 +++-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78edffc0..09797c12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/parsers/problem/CPythonUZProblemParser.ts b/src/parsers/problem/CPythonUZProblemParser.ts index 4fc12a95..9bc85687 100644 --- a/src/parsers/problem/CPythonUZProblemParser.ts +++ b/src/parsers/problem/CPythonUZProblemParser.ts @@ -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(); diff --git a/tests/before-functions.ts b/tests/before-functions.ts index 5364232f..dd0daf20 100644 --- a/tests/before-functions.ts +++ b/tests/before-functions.ts @@ -33,6 +33,10 @@ export const beforeFunctions: { [name: string]: (page: Page) => Promise } await page.waitForSelector('h1'); }, + async beforeCPythonUZ(page: Page): Promise { + await page.waitForSelector('h2.text-center, h2.content-header-title'); + }, + async beforeECNU(page: Page): Promise { await page.waitForSelector('.property > p > strong'); }, diff --git a/tests/data/cpython-uz/contest/normal.json b/tests/data/cpython-uz/contest/normal.json index 8d4be10b..defb0937 100644 --- a/tests/data/cpython-uz/contest/normal.json +++ b/tests/data/cpython-uz/contest/normal.json @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/tests/data/cpython-uz/problem/contest.json b/tests/data/cpython-uz/problem/contest.json index 4f968448..7fea6f6a 100644 --- a/tests/data/cpython-uz/problem/contest.json +++ b/tests/data/cpython-uz/problem/contest.json @@ -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" } ], diff --git a/tests/data/cpython-uz/problem/duel.json b/tests/data/cpython-uz/problem/duel.json index 7bffb2b8..6888f348 100644 --- a/tests/data/cpython-uz/problem/duel.json +++ b/tests/data/cpython-uz/problem/duel.json @@ -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": { diff --git a/tests/data/cpython-uz/problem/normal.json b/tests/data/cpython-uz/problem/normal.json index a64f2c10..799dcd78 100644 --- a/tests/data/cpython-uz/problem/normal.json +++ b/tests/data/cpython-uz/problem/normal.json @@ -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", @@ -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" } ],