From 2fda5a74ca9d560b68f10765a842c01147f99afe Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 25 Oct 2025 00:26:33 -0400 Subject: [PATCH] feat: codechef --- .busted | 13 - .github/workflows/test.yaml | 15 - README.md | 3 +- lua/cp/constants.lua | 3 +- pyproject.toml | 1 + scrapers/codechef.py | 280 + spec/execute_spec.lua | 11 - tests/conftest.py | 52 +- tests/fixtures/codechef_P1209.html | 4343 ++++++++++++ tests/fixtures/codechef_P2209.html | 5754 ++++++++++++++++ tests/fixtures/codechef_P3209.html | 5101 +++++++++++++++ tests/fixtures/codechef_P4209.html | 5940 +++++++++++++++++ tests/fixtures/codechef_P5209.html | 6175 ++++++++++++++++++ tests/fixtures/codechef_START209D.json | 202 + tests/fixtures/codechef_START209D_P1209.json | 99 + tests/fixtures/codechef_START209D_P2209.json | 85 + tests/fixtures/codechef_START209D_P3209.json | 85 + tests/fixtures/codechef_START209D_P4209.json | 85 + tests/fixtures/codechef_START209D_P5209.json | 85 + tests/fixtures/codechef_contests.json | 330 + tests/test_scrapers.py | 5 + uv.lock | 30 +- 22 files changed, 28652 insertions(+), 45 deletions(-) delete mode 100644 .busted create mode 100644 scrapers/codechef.py delete mode 100644 spec/execute_spec.lua create mode 100644 tests/fixtures/codechef_P1209.html create mode 100644 tests/fixtures/codechef_P2209.html create mode 100644 tests/fixtures/codechef_P3209.html create mode 100644 tests/fixtures/codechef_P4209.html create mode 100644 tests/fixtures/codechef_P5209.html create mode 100644 tests/fixtures/codechef_START209D.json create mode 100644 tests/fixtures/codechef_START209D_P1209.json create mode 100644 tests/fixtures/codechef_START209D_P2209.json create mode 100644 tests/fixtures/codechef_START209D_P3209.json create mode 100644 tests/fixtures/codechef_START209D_P4209.json create mode 100644 tests/fixtures/codechef_START209D_P5209.json create mode 100644 tests/fixtures/codechef_contests.json diff --git a/.busted b/.busted deleted file mode 100644 index f4945a0..0000000 --- a/.busted +++ /dev/null @@ -1,13 +0,0 @@ -return { - _all = { - coverage = false, - lpath = 'lua/?.lua;lua/?/init.lua', - lua = 'nlua', - }, - default = { - verbose = true, - }, - tests = { - verbose = true, - }, -} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 731ad4f..4c1cc1f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -35,21 +35,6 @@ jobs: - 'pyproject.toml' - 'uv.lock' - lua-test: - name: Lua Tests (${{ matrix.neovim_version }}) - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - strategy: - matrix: - neovim_version: ['stable', 'nightly'] - steps: - - uses: actions/checkout@v4 - - name: Run Lua tests - uses: nvim-neorocks/nvim-busted-action@v1 - with: - nvim_version: ${{ matrix.neovim_version }} - python-test: name: Python Tests runs-on: ubuntu-latest diff --git a/README.md b/README.md index 5d6088c..a0dd3ce 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ https://github.com/user-attachments/assets/956ec4c4-5ef1-4391-abea-3a51fa771809 ## Features -- **Multi-platform support**: AtCoder, Codeforces, CSES with consistent - interface +- **Multi-platform support**: AtCoder, CodeChef, Codeforces, and CSES - **Automatic problem setup**: Scrape test cases and metadata in seconds - **Dual view modes**: Lightweight I/O view for quick feedback, full panel for detailed analysis diff --git a/lua/cp/constants.lua b/lua/cp/constants.lua index 9d1f0cc..7bdaa16 100644 --- a/lua/cp/constants.lua +++ b/lua/cp/constants.lua @@ -1,10 +1,11 @@ local M = {} -M.PLATFORMS = { 'atcoder', 'codeforces', 'cses' } +M.PLATFORMS = { 'atcoder', 'codechef', 'codeforces', 'cses' } M.ACTIONS = { 'run', 'panel', 'next', 'prev', 'pick', 'cache', 'interact', 'edit' } M.PLATFORM_DISPLAY_NAMES = { atcoder = 'AtCoder', + codechef = 'CodeChef', codeforces = 'CodeForces', cses = 'CSES', } diff --git a/pyproject.toml b/pyproject.toml index b114d87..1e09ca4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ dev = [ "pytest-mock>=3.12.0", "pre-commit>=4.3.0", "basedpyright>=1.31.6", + "ruff>=0.14.2", ] [tool.pytest.ini_options] diff --git a/scrapers/codechef.py b/scrapers/codechef.py new file mode 100644 index 0000000..96d4cac --- /dev/null +++ b/scrapers/codechef.py @@ -0,0 +1,280 @@ +#!/usr/bin/env python3 + +import asyncio +import json +import re +import sys +from typing import Any + +import httpx +from scrapling.fetchers import StealthyFetcher + +from .base import BaseScraper +from .models import ( + ContestListResult, + ContestSummary, + MetadataResult, + ProblemSummary, + TestCase, + TestsResult, +) + +BASE_URL = "https://www.codechef.com" +API_CONTESTS_ALL = "/api/list/contests/all" +API_CONTEST = "/api/contests/{contest_id}" +API_PROBLEM = "/api/contests/{contest_id}/problems/{problem_id}" +PROBLEM_URL = "https://www.codechef.com/problems/{problem_id}" + +HEADERS = { + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" +} +TIMEOUT_S = 15.0 +CONNECTIONS = 8 + +MEMORY_LIMIT_RE = re.compile(r"Memory\s+[Ll]imit[:\s]+([0-9.]+)\s*MB", re.IGNORECASE) + + +async def fetch_json(client: httpx.AsyncClient, path: str) -> dict: + r = await client.get(BASE_URL + path, headers=HEADERS, timeout=TIMEOUT_S) + r.raise_for_status() + return r.json() + + +def _extract_memory_limit(html: str) -> float: + m = MEMORY_LIMIT_RE.search(html) + return float(m.group(1)) if m else 256.0 + + +def _fetch_html_sync(url: str) -> str: + response = StealthyFetcher.fetch(url, headless=True, network_idle=True) + return str(response.body) + + +def get_div4_contest_id(contest_id: str) -> str: + return f"{contest_id}D" + + +class CodeChefScraper(BaseScraper): + @property + def platform_name(self) -> str: + return "codechef" + + async def scrape_contest_metadata(self, contest_id: str) -> MetadataResult: + div4_id = get_div4_contest_id(contest_id) + async with httpx.AsyncClient() as client: + try: + data = await fetch_json(client, API_CONTEST.format(contest_id=div4_id)) + except httpx.HTTPStatusError as e: + return self._create_metadata_error( + f"Failed to fetch contest {contest_id}: {e}", contest_id + ) + + if not data.get("problems"): + return self._create_metadata_error( + f"No problems found for contest {contest_id}", contest_id + ) + + problems = [] + for problem_code, problem_data in data["problems"].items(): + problems.append( + ProblemSummary( + id=problem_code, + name=problem_data.get("name", problem_code), + ) + ) + + return MetadataResult( + success=True, + error="", + contest_id=contest_id, + problems=problems, + url=f"{BASE_URL}/{contest_id}", + ) + + async def scrape_contest_list(self) -> ContestListResult: + async with httpx.AsyncClient() as client: + try: + data = await fetch_json(client, API_CONTESTS_ALL) + except httpx.HTTPStatusError as e: + return self._create_contests_error(f"Failed to fetch contests: {e}") + + all_contests = data.get("future_contests", []) + data.get("past_contests", []) + + max_num = 0 + contest_names = {} + + for contest in all_contests: + contest_code = contest.get("contest_code", "") + if contest_code.startswith("START"): + match = re.match(r"START(\d+)", contest_code) + if match: + num = int(match.group(1)) + max_num = max(max_num, num) + contest_names[contest_code] = contest.get( + "contest_name", contest_code + ) + + if max_num == 0: + return self._create_contests_error("No Starters contests found") + + contests = [] + for i in range(1, max_num + 1): + contest_id = f"START{i}" + name = contest_names.get(contest_id, f"Starters {i}") + contests.append( + ContestSummary( + id=contest_id, + name=name, + display_name=name, + ) + ) + + return ContestListResult(success=True, error="", contests=contests) + + async def stream_tests_for_category_async(self, contest_id: str) -> None: + div4_id = get_div4_contest_id(contest_id) + + async with httpx.AsyncClient( + limits=httpx.Limits(max_connections=CONNECTIONS) + ) as client: + try: + contest_data = await fetch_json( + client, API_CONTEST.format(contest_id=div4_id) + ) + except Exception: + return + + problems = contest_data.get("problems", {}) + if not problems: + return + + sem = asyncio.Semaphore(CONNECTIONS) + + async def run_one(problem_code: str) -> dict[str, Any]: + async with sem: + try: + problem_data = await fetch_json( + client, + API_PROBLEM.format( + contest_id=div4_id, problem_id=problem_code + ), + ) + + sample_tests = ( + problem_data.get("problemComponents", {}).get( + "sampleTestCases", [] + ) + or [] + ) + tests = [ + TestCase( + input=t.get("input", "").strip(), + expected=t.get("output", "").strip(), + ) + for t in sample_tests + if not t.get("isDeleted", False) + ] + + time_limit_str = problem_data.get("max_timelimit", "1") + timeout_ms = int(float(time_limit_str) * 1000) + + problem_url = PROBLEM_URL.format(problem_id=problem_code) + loop = asyncio.get_event_loop() + html = await loop.run_in_executor( + None, _fetch_html_sync, problem_url + ) + memory_mb = _extract_memory_limit(html) + + interactive = False + + except Exception: + tests = [] + timeout_ms = 1000 + memory_mb = 256.0 + interactive = False + + return { + "problem_id": problem_code, + "tests": [ + {"input": t.input, "expected": t.expected} for t in tests + ], + "timeout_ms": timeout_ms, + "memory_mb": memory_mb, + "interactive": interactive, + } + + tasks = [run_one(problem_code) for problem_code in problems.keys()] + for coro in asyncio.as_completed(tasks): + payload = await coro + print(json.dumps(payload), flush=True) + + +async def main_async() -> int: + if len(sys.argv) < 2: + result = MetadataResult( + success=False, + error="Usage: codechef.py metadata OR codechef.py tests OR codechef.py contests", + url="", + ) + print(result.model_dump_json()) + return 1 + + mode: str = sys.argv[1] + scraper = CodeChefScraper() + + if mode == "metadata": + if len(sys.argv) != 3: + result = MetadataResult( + success=False, + error="Usage: codechef.py metadata ", + url="", + ) + print(result.model_dump_json()) + return 1 + contest_id = sys.argv[2] + result = await scraper.scrape_contest_metadata(contest_id) + print(result.model_dump_json()) + return 0 if result.success else 1 + + if mode == "tests": + if len(sys.argv) != 3: + tests_result = TestsResult( + success=False, + error="Usage: codechef.py tests ", + problem_id="", + tests=[], + timeout_ms=0, + memory_mb=0, + ) + print(tests_result.model_dump_json()) + return 1 + contest_id = sys.argv[2] + await scraper.stream_tests_for_category_async(contest_id) + return 0 + + if mode == "contests": + if len(sys.argv) != 2: + contest_result = ContestListResult( + success=False, error="Usage: codechef.py contests" + ) + print(contest_result.model_dump_json()) + return 1 + contest_result = await scraper.scrape_contest_list() + print(contest_result.model_dump_json()) + return 0 if contest_result.success else 1 + + result = MetadataResult( + success=False, + error=f"Unknown mode: {mode}. Use 'metadata ', 'tests ', or 'contests'", + url="", + ) + print(result.model_dump_json()) + return 1 + + +def main() -> None: + sys.exit(asyncio.run(main_async())) + + +if __name__ == "__main__": + main() diff --git a/spec/execute_spec.lua b/spec/execute_spec.lua deleted file mode 100644 index 12d85d2..0000000 --- a/spec/execute_spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -describe('run module', function() - local run = require('cp.runner.run') - - describe('basic functionality', function() - it('can get panel state', function() - local state = run.get_panel_state() - assert.is_table(state) - assert.is_table(state.test_cases) - end) - end) -end) diff --git a/tests/conftest.py b/tests/conftest.py index dfd8e7c..5970960 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -136,12 +136,12 @@ def run_scraper_offline(fixture_text): case "codeforces": - class MockPage: + class MockCodeForcesPage: def __init__(self, html: str): self.html_content = html def _mock_stealthy_fetch(url: str, **kwargs): - return MockPage(_router_codeforces(url=url)) + return MockCodeForcesPage(_router_codeforces(url=url)) def _mock_requests_get(url: str, **kwargs): if "api/contest.list" in url: @@ -176,6 +176,51 @@ def run_scraper_offline(fixture_text): "requests.get": _mock_requests_get, } + case "codechef": + + class MockResponse: + def __init__(self, json_data): + self._json_data = json_data + self.status_code = 200 + + def json(self): + return self._json_data + + def raise_for_status(self): + pass + + async def __offline_get_async(client, url: str, **kwargs): + if "/api/list/contests/all" in url: + data = json.loads(fixture_text("codechef_contests.json")) + return MockResponse(data) + if "/api/contests/START209D" in url and "/problems/" not in url: + data = json.loads(fixture_text("codechef_START209D.json")) + return MockResponse(data) + if "/api/contests/START209D/problems/" in url: + problem_id = url.rstrip("/").split("/")[-1] + data = json.loads( + fixture_text(f"codechef_START209D_{problem_id}.json") + ) + return MockResponse(data) + raise AssertionError(f"No fixture for CodeChef url={url!r}") + + class MockCodeChefPage: + def __init__(self, html: str): + self.body = html + self.status = 200 + + def _mock_stealthy_fetch(url: str, **kwargs): + if "/problems/" in url: + problem_id = url.rstrip("/").split("/")[-1] + html = fixture_text(f"codechef_{problem_id}.html") + return MockCodeChefPage(html) + raise AssertionError(f"No fixture for CodeChef url={url!r}") + + return { + "__offline_get_async": __offline_get_async, + "StealthyFetcher.fetch": _mock_stealthy_fetch, + } + case _: raise AssertionError(f"Unknown scraper: {scraper_name}") @@ -192,6 +237,9 @@ def run_scraper_offline(fixture_text): ns._get_async = offline_fetches["_get_async"] elif scraper_name == "cses": httpx.AsyncClient.get = offline_fetches["__offline_fetch_text"] # type: ignore[assignment] + elif scraper_name == "codechef": + httpx.AsyncClient.get = offline_fetches["__offline_get_async"] # type: ignore[assignment] + fetchers.StealthyFetcher.fetch = offline_fetches["StealthyFetcher.fetch"] # type: ignore[assignment] main_async = getattr(ns, "main_async") assert callable(main_async), f"main_async not found in {scraper_name}" diff --git a/tests/fixtures/codechef_P1209.html b/tests/fixtures/codechef_P1209.html new file mode 100644 index 0000000..2ab7eb3 --- /dev/null +++ b/tests/fixtures/codechef_P1209.html @@ -0,0 +1,4343 @@ + + + + + + + + + + + + + + + Bitcoin Market Practice Coding Problem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+ Difficulty:172 +
+
+ +
+
+ Expand +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ Learn the building blocks of programming + languages +
+
+
+ Take our free programming courses and learn to + solve problems like these. +
+ Start Learning +
+
+

Bitcoin Market

+

+ Chef has recently started investing in + Bitcoin.
+ He assigns a + market risk level + RR + (from + 11 + to + 1010), where: +

+
    +
  • + 11 + means the market is very safe, +
  • +
  • + 1010 + means the market is very risky. +
  • +
+

+ Chef will buy Bitcoin only if + the risk level is + 44 + or less. +

+

+ Given the current risk level + RR, determine whether Chef should buy Bitcoin. +

+

+ Print "YES" if Chef should + buy, otherwise print "NO". +

+
+

Input Format

+
    +
  • + The first and only line of input contains + a single integer + RR + — the current market risk level. +
  • +
+
+
+

Output Format

+

+ Print YES if Chef should buy + Bitcoin, Otherwise, print NO. +

+

+ You may print each character of the string + in uppercase or lowercase (for example, the + strings YES, yEs, + yes, and yeS will + all be treated as identical). +

+
+

Constraints

+
+
    +
  • + 1R101 \leq R \leq 10 +
  • +
+
+

Sample 1:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
2
+
+
+
YES
+
+
+
+

Explanation:

+
+

+ The current market risk is + 22.
+ Since + 22 + is not larger than + 44, the risk is small enough, and Chef will + buy Bitcoin. +

+
+

Sample 2:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
4
+
+
+
YES
+
+
+
+

Explanation:

+
+

+ The current market risk is + 44.
+ Since + 44 + is not larger than + 44, the risk is small enough, and Chef will + buy Bitcoin. +

+
+

Sample 3:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
5
+
+
+
NO
+
+
+
+

Explanation:

+
+

+ The current market risk is + 55.
+ Since + 55 + is larger than + 44, the risk is too much, and Chef will + not buy Bitcoin. +

+
+
+
+
+
+
+
+
+ More Info +
+
+
+ Time limit1 secs +
+
+ Memory limit1.5 GB +
+
+ Source Limit50000 Bytes +
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+
+ Author(s) + +
+
+ Tester(s) +
+ kingmessi +
+
+
+ Editorialist(s) + +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
    +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ #include + <bits/stdc++.h> +
+
+
+
+ using + namespace + std; +
+
+
+
+
+
+
+ int + main() + { +
+
+
+
+ // your code goes here +
+
+
+
+
+
+
+ } +
+
+
+
+
+
+
+
+
+
+
+
+
+
+   +
+
+
+
+   +
+
+
+
+ הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה +
+
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +
+
+ +
+
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ Visualize Code +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ + +
+
+ +
+ + diff --git a/tests/fixtures/codechef_P2209.html b/tests/fixtures/codechef_P2209.html new file mode 100644 index 0000000..97d86ac --- /dev/null +++ b/tests/fixtures/codechef_P2209.html @@ -0,0 +1,5754 @@ + + + + + + + + + + + + + + + Divisible Duel Practice Coding Problem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+ Difficulty:628 +
+
+ +
+
+ Expand +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ Learn the building blocks of programming + languages +
+
+
+ Take our free programming courses and learn to + solve problems like these. +
+ Start Learning +
+
+

Divisible Duel

+

+ Alice loves working with numbers. One day, she + takes two integers + XX + and + YY + (YXY \ge X) and becomes curious about the numbers + between them. +

+

+ She looks at all integers between + XX + and + YY + (inclusive) that are divisible by + XX.
+ Among these numbers, she separates them into + even and odd numbers. +

+

+ Let the sum of all even numbers Alice has be + SevenS_{even}, and the sum of all odd numbers she has be + SoddS_{odd}. +

+

+ If + SevenSoddS_{even} \ge S_{odd}, Alice will be happy; otherwise, she will be + sad.
+ Alice wants to know whether she will be happy + or not. +

+
+

Input Format

+
    +
  • + The first line contains a single integer + TT + — the number of test cases. +
  • +
  • + Each of the next + TT + lines contains two integers + XX + and + YY, representing the lower and upper bound + of integers Alice looked at. +
  • +
+
+
+

Output Format

+

+ For each test case, print the answer on a + new line: YES if Alice will be + happy, otherwise NO. +

+

+ You may print each character of the answer + in uppercase either or lowercase (for + example, the strings YES, + yEs, yes, and + yeS will all be treated as + identical). +

+
+

Constraints

+
+
    +
  • + 1T1041 \leq T \leq + 10^4 +
  • +
  • + 1X,Y1001 \leq X,Y \leq + 100 +
  • +
+
+

Sample 1:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
+3
+1 4
+3 9
+4 100
+
+
+
+
+YES
+NO
+YES
+
+
+
+

Explanation:

+
+

+ Test case + 11: + Alice has + X=1X = 1 + and + Y=4Y = 4.
+ The multiples of + XX + in this range are + 1,2,3,41, 2, 3, 4.
+ So, + Seven=2+4=6S_{even} = 2+4 = 6, and + Sodd=1+3=4S_{odd} = 1+3 = 4.
+ Since + SevenSoddS_{even} \ge + S_{odd}, Alice is happy. +

+

+ Test case + 22: + Alice has + X=3X = 3 + and + Y=9Y = 9.
+ The multiples of + XX + in this range are + 3,6,93, 6, 9. So, + Seven=6S_{even} = 6, and + Sodd=3+9=12S_{odd} = 3+9 = 12.
+ Since + Seven<SoddS_{even} \lt + S_{odd}, Alice is not happy. +

+
+
+
+
+
+
+
+
+ More Info +
+
+
+ Time limit1 secs +
+
+ Memory limit1.5 GB +
+
+ Source Limit50000 Bytes +
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+
+ Author(s) + +
+
+ Tester(s) +
+ kingmessi +
+
+
+ Editorialist(s) + +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
    +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ #include + <bits/stdc++.h> +
+
+
+
+ using + namespace + std; +
+
+
+
+
+
+
+ int + main() + { +
+
+
+
+ // your code goes here +
+
+
+
+
+
+
+ } +
+
+
+
+
+
+
+
+
+
+
+
+
+
+   +
+
+
+
+   +
+
+
+
+ הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה +
+
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +
+
+ +
+
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ Visualize Code +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ + +
+
+ +
+ + diff --git a/tests/fixtures/codechef_P3209.html b/tests/fixtures/codechef_P3209.html new file mode 100644 index 0000000..15fb3a4 --- /dev/null +++ b/tests/fixtures/codechef_P3209.html @@ -0,0 +1,5101 @@ + + + + + + + + + + + + + + + Small GCD Sort Practice Coding Problem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+ Difficulty:1039 +
+
+ +
+
+ Expand +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ Learn the building blocks of programming + languages +
+
+
+ Take our free programming courses and learn to + solve problems like these. +
+ Start Learning +
+
+

Small GCD Sort

+

+ There are + NN + players, numbered from + 11 + to + NN. +

+

+ Player + ii's score is defined to be + gcd(i,N)\gcd(i, N).
+ Here, + gcd(i,N)\gcd(i, N) + refers to the largest positive integer that + divides both + ii + and + NN. +

+

+ Your task is to find an ordering of the + players, from left to right, that satisfies + the following conditions: +

+
    +
  • + Between two players with different scores, + the one with a higher score must appear + somewhere to the left of the one with a + lower score. +
  • +
  • + Between two players with the same score, the + player with a smaller number must appear + somewhere to the left of the one with a + lower score. +
  • +
+

+ It can be proved that these rules uniquely + define an ordering of the + NN + people.
+ Your task is to find this ordering. +

+
+

Input Format

+
    +
  • + The first line contains a single integer + TT + — the number of test cases. +
  • +
  • + Each of the next + TT + lines contains a single integer + NN + — the number of players. +
  • +
+
+
+

Output Format

+

+ For each test case, print + NN + space-separated integers on a new line — the + player numbers in the required preference + order. +

+
+

Constraints

+
+
    +
  • + 1T1001 \leq T \leq 100 +
  • +
  • + 1N1001 \leq N \leq 100 +
  • +
+
+

Sample 1:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
+5
+1
+2
+3
+4
+5
+
+
+
+1
+2 1
+3 1 2
+4 2 1 3
+5 1 2 3 4
+
+
+
+

Explanation:

+
+

+ Test case + 11: + There is only one player. +

+

+ Test case + 22: + There are two players.
+ Player + 11 + has a score of + gcd(1,2)=1\gcd(1, 2) = 1, while player + 22 + has a score of + gcd(2,2)=2\gcd(2, 2) = 2.
+ Player + 22 + has a higher score, and so appears to the + left of player + 11, making the only possible order + [2,1][2, 1]. +

+

+ Test case + 44: + There are four players. It can be verified + that players + 11 + and + 33 + have a score of + 11, player + 22 + has a score of + 22, and player + 44 + has a score of + 44.
+ So, +

+
    +
  • + Player + 44 + has the highest score, and so must be + placed first. +
  • +
  • + Player + 22 + has the second highest score, and so must + be placed second. +
  • +
  • + Players + 11 + and + 33 + have the same score.
    + Among them, + 11 + has the smaller number, and so must be + placed ahead of + 33. +
  • +
+

+ Thus, the final order is + [4,2,1,3][4, 2, 1, 3]. +

+
+
+
+
+
+
+
+
+ More Info +
+
+
+ Time limit1 secs +
+
+ Memory limit1.5 GB +
+
+ Source Limit50000 Bytes +
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+
+ Author(s) + +
+
+ Tester(s) +
+ kingmessi +
+
+
+ Editorialist(s) + +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
    +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ #include + <bits/stdc++.h> +
+
+
+
+ using + namespace + std; +
+
+
+
+
+
+
+ int + main() + { +
+
+
+
+ // your code goes here +
+
+
+
+
+
+
+ } +
+
+
+
+
+
+
+
+
+
+
+
+
+
+   +
+
+
+
+   +
+
+
+
+ הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה +
+
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +
+
+ +
+
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ Visualize Code +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ +
+ +
+ +
+ + diff --git a/tests/fixtures/codechef_P4209.html b/tests/fixtures/codechef_P4209.html new file mode 100644 index 0000000..554a3c3 --- /dev/null +++ b/tests/fixtures/codechef_P4209.html @@ -0,0 +1,5940 @@ + + + + + + + + + + + + + + + Tactical Conversion Practice Coding Problem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+ Difficulty:1626 +
+
+ +
+
+ Expand +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ Learn the building blocks of programming + languages +
+
+
+ Take our free programming courses and learn to + solve problems like these. +
+ Start Learning +
+
+

Tactical Conversion

+

+ You are given a binary string + SS + of length + NN, i.e. each character of + SS + is either + 00 + or + 11. +

+

+ You would like to convert every character of + SS + into + 00.
+ To achieve this, you can perform the following + operation: +

+
    +
  • + Choose an index + ii + (1iN)(1 \le i \le N) + such that + Si=1S_i = 1, and change + SiS_i + to + 00. +
  • +
+

+ However, there is one restriction:
+ You cannot perform two consecutive operations + on adjacent indices.
+ That is, if you operate on the sequence of + indices + i1,i2,,iki_1, i_2, \ldots, i_k, then for each + 1j<k1 \le j \lt k + the condition + ijij+1>1|i_j - i_{j+1}| \gt 1 + must hold. +

+

+ Determine whether it is possible to make the + entire string consist of only zeros under + these conditions. +

+
+

Input Format

+
    +
  • + The first line of input contains a single + integer + TT, denoting the number of test cases. +
  • +
  • + Each test case consists of two lines of + input: +
      +
    • + The first line contains a single + integer + NN + — the length of the binary string. +
    • +
    • + The second line contains the binary + string + SS + of length + NN, consisting only of characters + 0 and 1. +
    • +
    +
  • +
+
+
+

Output Format

+

+ For each test case, output a single string + on a new line — YES if it is + possible to convert the entire string to all + zeros under the given rule, or + NO otherwise. +

+

+ You may print each character of the string + in uppercase or lowercase (for example, the + strings YES, yEs, + yes, and yeS will + all be treated as identical). +

+
+

Constraints

+
+
    +
  • + 1T21051 \leq T \leq 2\cdot + 10^5 +
  • +
  • + 1N21051 \leq N \leq 2\cdot + 10^5 +
  • +
  • + SS + is a binary string. +
  • +
  • + The sum of + NN + over all test cases won't exceed + 21052\cdot 10^5. +
  • +
+
+

Sample 1:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
+5
+2
+00
+3
+001
+3
+101
+3
+111
+2
+11
+
+
+
+
+Yes
+Yes
+Yes
+No
+No
+
+
+
+

Explanation:

+
+

+ Test case + 11: + No operations are needed. +

+

+ Test case + 22: + There is a single + 11 + at position + 33.
+ Simply perform one operation with + i=3i = 3, and the string becomes + 000000 + as desired. +

+

+ Test case + 33: + There are two + 11's, at positions + 11 + and + 33.
+ Perform one operation with + i=1i = 1, and the next operation with + i=3i = 3, and we're done. +

+

+ Test case + 44: + There are three ones, at positions + 1,2,31, 2, 3.
+ It's not possible to operate on all of them, + because: +

+
    +
  • + If our first operation is on index + 11, the second operation cannot be index + 22 + and so must be index + 33.
    + But then after index + 33 + we cannot operate on index + 22 + anyway, so that index will continue to + contain a + 11. +
  • +
  • + Similarly, the first operation being on + index + 33 + will leave us unable to operate on index + 22. +
  • +
  • + Finally, if the first operation is on + index + 22, then the second operation cannot be on + either index + 11 + or index + 33 + since they're both adjacent to it. +
  • +
+

+ Thus, there's no way to make everything + 00. +

+
+
+
+
+
+
+
+
+ More Info +
+
+
+ Time limit1 secs +
+
+ Memory limit1.5 GB +
+
+ Source Limit50000 Bytes +
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+
+ Author(s) + +
+
+ Tester(s) +
+ kingmessi +
+
+
+ Editorialist(s) + +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
    +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ #include + <bits/stdc++.h> +
+
+
+
+ using + namespace + std; +
+
+
+
+
+
+
+ int + main() + { +
+
+
+
+ // your code goes here +
+
+
+
+
+
+
+ } +
+
+
+
+
+
+
+
+
+
+
+
+
+
+   +
+
+
+
+   +
+
+
+
+ הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה +
+
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +
+
+ +
+
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ Visualize Code +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ + +
+
+ +
+ + diff --git a/tests/fixtures/codechef_P5209.html b/tests/fixtures/codechef_P5209.html new file mode 100644 index 0000000..a7b7aa9 --- /dev/null +++ b/tests/fixtures/codechef_P5209.html @@ -0,0 +1,6175 @@ + + + + + + + + + + + + + + + Binary Love Practice Coding Problem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+ Difficulty:1536 +
+
+ +
+
+ Expand +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ Learn the building blocks of programming + languages +
+
+
+ Take our free programming courses and learn to + solve problems like these. +
+ Start Learning +
+
+

Binary Love

+

+ Alice and Bob are playing a game on a binary + string + SS + of length + NN. +

+

+ Alice wants to make the number of substrings + 01 and 10 equal, and + both counts must be non-zero.
+ Formally, let + c01c_{01} + denote the number of indices + ii + (1i<N1 \le i \lt N) such that + Si=0S_i = 0 + and + Si+1=1S_{i+1} = 1, and similarly let + c10c_{10} + denote the number of indices + ii + (1i<N1 \le i \lt N) such that + Si=1S_i = 1 + and + Si+1=0S_{i+1} = 0.
+ Alice would like for + c01=c10c_{01} = c_{10} + and + c01>0c_{01} \gt 0 + to both hold. +

+

+ Bob, on the other hand, wants to prevent Alice + from achieving this condition. +

+

+ The players take turns alternately, with Alice + going first.
+ In each turn, the current player can remove + exactly one character from either the + beginning or the end of the string. +

+

+ The game ends immediately when the string + becomes empty or when Alice's desired + condition (c01=c10>0c_{01} = c_{10} \gt 0) is satisfied. +

+

+ If Alice can make the number of + 01 and 10 substrings + equal (and both non-zero), she wins.
+ Otherwise, if Bob can prevent this condition + until the string becomes empty, Bob wins.
+ In particular, if the initial string satisfies + the required condition, Alice wins + immediately, without even having to make a + move. +

+

+ Determine the winner of the game if both + players play optimally. +

+
+

Input Format

+
    +
  • + The first line of input contains a single + integer + TT, denoting the number of test cases. +
  • +
  • + Each test case consists of two lines of + input: +
      +
    • + The first line contains a single + integer + NN + — the length of the binary string. +
    • +
    • + The second line contains the binary + string + SS + of length + NN, consisting only of characters + 0 and 1. +
    • +
    +
  • +
+
+
+

Output Format

+

+ For each test case, output a single string — + Alice if Alice wins the game, + or Bob if Bob wins the game. +

+

+ You may print each character of the string + in uppercase or lowercase (for example, the + strings BOB, bOb, + bob, and boB will + all be treated as identical). +

+
+

Constraints

+
+
    +
  • + 1T21051 \leq T \leq 2\cdot + 10^5 +
  • +
  • + 1N21051 \leq N \leq 2\cdot + 10^5 +
  • +
  • + Si{0,1}S_i \in \{0, 1\} +
  • +
  • + The sum of + NN + over all test cases won't exceed + 21052\cdot10^5. +
  • +
+
+

Sample 1:

+
+
+
+ Input +
+ +
+
+
+ Output +
+ +
+
+
+
+
+
+4
+3
+000
+3
+010
+4
+0001
+4
+0101
+
+
+
+Bob
+Alice
+Bob
+Alice
+
+
+
+

Explanation:

+
+

+ Test case + 11: + We have + c01=c10=0c_{01} = c_{10} = 0 + for the initial string.
+ No matter what the players do in terms of + deleting characters, this won't change.
+ Alice wants + c01>0c_{01} \gt 0, so she cannot win here. +

+

+ Test case + 22: + We have + c01=c10=1c_{01} = c_{10} = 1 + initially.
+ Alice's condition is already satisfied, so + she wins immediately. +

+

+ Test case + 44: + We have + S=0101S = 0101, for which + c01=2c_{01} = 2 + and + c10=1c_{10} = 1.
+ Alice must make a move; she can delete the + last character to make + S=010S = 010 + which as seen earlier satisfies Alice's + condition; so Alice wins. +

+
+
+
+
+
+
+
+
+ More Info +
+
+
+ Time limit1 secs +
+
+ Memory limit1.5 GB +
+
+ Source Limit50000 Bytes +
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+
+ Author(s) + +
+
+ Tester(s) +
+ kingmessi +
+
+
+ Editorialist(s) + +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
    +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ #include + <bits/stdc++.h> +
+
+
+
+ using + namespace + std; +
+
+
+
+
+
+
+ int + main() + { +
+
+
+
+ // your code goes here +
+
+
+
+
+
+
+ } +
+
+
+
+
+
+
+
+
+
+
+
+
+
+   +
+
+
+
+   +
+
+
+
+ הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה +
+
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +
+
+ +
+
+
+
+
+
+
+
+

+ +

+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ Visualize Code +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ +
+ +
+ +
+ + diff --git a/tests/fixtures/codechef_START209D.json b/tests/fixtures/codechef_START209D.json new file mode 100644 index 0000000..bad4c78 --- /dev/null +++ b/tests/fixtures/codechef_START209D.json @@ -0,0 +1,202 @@ +{ + "status": "success", + "user": { "username": null }, + "code": "START209D", + "isRatedContest": "1", + "isParentContestRated": "1", + "name": "Starters 209 (Rated)", + "problems": { + "P1209": { + "code": "P1209", + "name": "Bitcoin Market", + "type": "3", + "successful_submissions": "25131", + "allow_submission": false, + "accuracy": 85.680000000000007, + "problem_url": "\/problems\/P1209", + "submit_url": "\/problems\/P1209", + "status_url": "\/status\/P1209", + "is_added_to_practice": true, + "total_submissions": "33093", + "category_name": "main", + "is_direct_submittable": false + }, + "P2209": { + "code": "P2209", + "name": "Divisible Duel", + "type": "3", + "successful_submissions": "21888", + "allow_submission": false, + "accuracy": 64.159999999999997, + "problem_url": "\/problems\/P2209", + "submit_url": "\/problems\/P2209", + "status_url": "\/status\/P2209", + "is_added_to_practice": true, + "total_submissions": "37437", + "category_name": "main", + "is_direct_submittable": false + }, + "P3209": { + "code": "P3209", + "name": "Small GCD Sort", + "type": "3", + "successful_submissions": "13450", + "allow_submission": false, + "accuracy": 76.239999999999995, + "problem_url": "\/problems\/P3209", + "submit_url": "\/problems\/P3209", + "status_url": "\/status\/P3209", + "is_added_to_practice": true, + "total_submissions": "19164", + "category_name": "main", + "is_direct_submittable": false + }, + "P4209": { + "code": "P4209", + "name": "Tactical Conversion", + "type": "3", + "successful_submissions": "1567", + "allow_submission": false, + "accuracy": 8.4499999999999993, + "problem_url": "\/problems\/P4209", + "submit_url": "\/problems\/P4209", + "status_url": "\/status\/P4209", + "is_added_to_practice": true, + "total_submissions": "20535", + "category_name": "main", + "is_direct_submittable": false + }, + "P5209": { + "code": "P5209", + "name": "Binary Love", + "type": "3", + "successful_submissions": "3271", + "allow_submission": false, + "accuracy": 33.530000000000001, + "problem_url": "\/problems\/P5209", + "submit_url": "\/problems\/P5209", + "status_url": "\/status\/P5209", + "is_added_to_practice": true, + "total_submissions": "11128", + "category_name": "main", + "is_direct_submittable": false + }, + "P6209E": { + "code": "P6209E", + "name": "High Score (Easy Version)", + "type": "3", + "successful_submissions": "285", + "allow_submission": false, + "accuracy": 7.2800000000000002, + "problem_url": "\/problems\/P6209E", + "submit_url": "\/problems\/P6209E", + "status_url": "\/status\/P6209E", + "is_added_to_practice": true, + "total_submissions": "4535", + "category_name": "main", + "is_direct_submittable": false + }, + "P6209": { + "code": "P6209", + "name": "High Score (Hard Version)", + "type": "3", + "successful_submissions": "34", + "allow_submission": false, + "accuracy": 3.1899999999999999, + "problem_url": "\/problems\/P6209", + "submit_url": "\/problems\/P6209", + "status_url": "\/status\/P6209", + "is_added_to_practice": true, + "total_submissions": "1159", + "category_name": "main", + "is_direct_submittable": false + }, + "P7209": { + "code": "P7209", + "name": "Easy Grid Game", + "type": "3", + "successful_submissions": "80", + "allow_submission": false, + "accuracy": 5.1100000000000003, + "problem_url": "\/problems\/P7209", + "submit_url": "\/problems\/P7209", + "status_url": "\/status\/P7209", + "is_added_to_practice": true, + "total_submissions": "1740", + "category_name": "main", + "is_direct_submittable": false + }, + "P8209": { + "code": "P8209", + "name": "Counting Is Fun", + "type": "3", + "successful_submissions": "22", + "allow_submission": false, + "accuracy": 1.8200000000000001, + "problem_url": "\/problems\/P8209", + "submit_url": "\/problems\/P8209", + "status_url": "\/status\/P8209", + "is_added_to_practice": true, + "total_submissions": "1261", + "category_name": "main", + "is_direct_submittable": false + } + }, + "banner": "https:\/\/cdn.codechef.com\/download\/small-banner\/START209D\/1760933097.png", + "rules": "

CodeChef: A Platform for Aspiring Programmers<\/h4>\n

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming, and programming contests. At CodeChef, our dedicated efforts are aimed at reviving the inner geek within you, as we proudly host a thrilling programming (coding) contest every Wednesday.<\/p>\n

About CodeChef Starters:<\/h4>\n

CodeChef Starters is a short programming contest which takes place on every Wednesday\u00a0<\/p>\n

Contest Details:<\/h4>\n