c-code-x / codex-website

https://codex-website-nu.vercel.app
5 stars 17 forks source link

CF Problem Sheet Backend API added #76

Closed Harsha9554 closed 7 months ago

Harsha9554 commented 7 months ago

This PR address the feature request issue #74 and it's sub issue which is #75 to develop a CodeForces Problem Sheet Backend API.

Here's why this PR would be a game-changer for our CP group:

  1. Targeted Skill Improvement:

    • Ever felt the need to hone your skills in a particular rating range? With this feature, you can tailor your practice to match your current level and challenge yourself to the next one.
  2. Latest Contest Insights:

    • Stay ahead of the game by accessing problems from the most recent contests. The feature will intelligently order problems so that you can grasp the latest patterns and strategies employed in the recent contests.
  3. Efficient Problem Management:

    • No more sifting through irrelevant problems. Easily distinguish between problems you've solved, attempted, or haven't touched. It's a streamlined approach to managing your problem-solving journey.

Features Handled in this PR:

  1. Fetch Problems by Rating Range:

    • Users should be able to fetch all problems from recent contests within a given rating range (e.g., 1100 to 1200).
    • The fetched problems should be ordered based on the most recent contests, providing insight into the latest contest patterns.
  2. Distinguish Problem Status:

    • Users should have the ability to distinguish between problems they have solved, attempted, and so on.
    • This feature enhances the user experience by providing a clear overview of their progress.

Design for the API call:

API Endpoint:

GET http://localhost:3000/api/cf-problem-sheet

Query Parameters:

Example Request:

GET http://localhost:3000/api/cf-problem-sheet?handle=harsha_9554&maxProblemRating=1400&numberOfPreviousContests=3

Example Response:

{
    "meta": {
        "handle": "harsha_9554",
        "minProblemRating": 0,
        "maxProblemRating": 1400,
        "numberOfPreviousContests": 3
    },
    "problems": [
        {
            "contestId": 1903,
            "index": "A",
            "name": "Halloumi Boxes",
            "type": "PROGRAMMING",
            "points": 500,
            "rating": 800,
            "tags": [
                "brute force",
                "greedy",
                "sortings"
            ],
            "verdict": "NONE",
            "URL": "https://codeforces.com/problemset/problem/1903/A"
        },
        {
            "contestId": 1903,
            "index": "B",
            "name": "StORage room",
            "type": "PROGRAMMING",
            "points": 1000,
            "rating": 1200,
            "tags": [
                "bitmasks",
                "brute force",
                "constructive algorithms",
                "greedy"
            ],
            "verdict": "NONE",
            "URL": "https://codeforces.com/problemset/problem/1903/B"
        },
        {
            "contestId": 1903,
            "index": "C",
            "name": "Theofanis' Nightmare",
            "type": "PROGRAMMING",
            "points": 1500,
            "rating": 1400,
            "tags": [
                "constructive algorithms",
                "greedy"
            ],
            "verdict": "NONE",
            "URL": "https://codeforces.com/problemset/problem/1903/C"
        }
    ]
}

Finally, This PR solves #75, part of #74. Please review the changes and let me know if there are any issues or if further adjustments are needed. @Jaideep-C