Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Implements automated solution generation for daily LeetCode problems using OpenAI's GPT-5-mini, running at 00:01 UTC.

Changes

  • .github/workflows/auto_solver.yml: Daily workflow with explicit contents: write permissions
  • auto_solver.py: Fetches problem via LeetCode GraphQL API, generates solution with GPT-5-mini, saves as problems/{ID}/gpt5-mini.md
  • README.md: Added auto-solver documentation

Generated Solution Format

Solutions follow existing template structure:

# [Problem {ID}: {Title}]({Link})

## Initial thoughts (stream-of-consciousness)
[AI analysis]

## Refining the problem, round 2 thoughts
[Complexity considerations]

## Attempted solution(s)
[Python solution with implementation notes]

Configuration Required

Set OPENAI_API_KEY repository secret before merge. Workflow can also be triggered manually via Actions UI.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • leetcode.com
    • Triggering command: `python3 -c
      import requests
      import json

Test fetching the daily problem

leetcode_api_url = 'REDACTED'
daily_challenge_query = {
'query': '''query questionOfToday {
activeDailyCodingChallengeQuestion {
date
link
question {
questionFrontendId
title
titleSlug
difficulty
content
}
}
}''',
'operationName': 'questionOfToday'
}

response = requests.post(leetcode_api_url, json=daily_challenge_query)
data = response.json()

if 'data' in data and 'activeDailyCodingChallengeQuestion' in data['data']:
question = data['data']['activeDailyCodingChallengeQuestion']['question']
print(f'✓ Successfully fetched daily problem:')
print(f' Problem ID: {question["questionFrontendId"]}')
print(f' Title: {question["title"]}')
print(f' Difficulty: {question["difficulty"]}')
print(f' Content length: {len(question["content"])} characters')
else:
print('✗ Failed to fetch problem')
print(json.dumps(data, indent=2))` (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>auto-solver?</issue_title>
<issue_description>It could be interesting to add in an "automatic solver" for each day's problem. E.g., could we construct an action to do the following (run each day at 0:01 UTC):

  • fetch the daily problem
  • store the text of the problem in a "problems" directory
  • use langchain/chatgpt to solve the problem, describing the thought process and code using the attached template
  • add chatgpt's solution under problems//chatgpt.md
  • commit the notes/solution</issue_description>

Comments on the Issue (you are @copilot in this section)

@jeremymanning Updates: - Use GPT-5 mini to create each day's solution (API key is stored as a repo secret: OPENAI_API_KEY)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 5, 2025 14:04
Co-authored-by: jeremymanning <9030494+jeremymanning@users.noreply.github.com>
Co-authored-by: jeremymanning <9030494+jeremymanning@users.noreply.github.com>
Co-authored-by: jeremymanning <9030494+jeremymanning@users.noreply.github.com>
Copilot AI changed the title [WIP] Add automatic solver for daily problems Add GPT-5-mini auto-solver for daily LeetCode problems Nov 5, 2025
Copilot AI requested a review from jeremymanning November 5, 2025 14:13
Copilot finished work on behalf of jeremymanning November 5, 2025 14:13
@jeremymanning
Copy link
Member

@copilot Since we can't test the key elements of this implementation here (i.e., fetching the leetcode problem doesn't work because we don't have access to external sites, and we can't access repository secrets to get the openai API key), add a comment ot the pull request with instructions for manually testing the solution before I merge.

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot Since we can't test the key elements of this implementation here (i.e., fetching the leetcode problem doesn't work because we don't have access to external sites, and we can't access reposito...

Manual Testing Instructions

Since this PR cannot be fully tested in the PR environment, follow these steps to test before merging:

Prerequisites

  1. Ensure OPENAI_API_KEY repository secret is set with a valid GPT-5-mini API key
  2. Have access to the repository's Actions tab

Testing Steps

1. Manual Workflow Trigger Test

  1. Go to Actions"Auto-solve Daily LeetCode Problem"
  2. Click "Run workflow" → Select main branch → Click "Run workflow"
  3. Monitor the workflow execution:
    • ✓ Check that Python 3.11 installs successfully
    • ✓ Check that requests and openai packages install
    • ✓ Verify script fetches today's problem (look for problem ID/title in logs)
    • ✓ Confirm GPT-5-mini generates a solution (watch for "Solution generated successfully!")
    • ✓ Verify file is saved to problems/{PROBLEM_ID}/gpt5-mini.md
    • ✓ Confirm auto-commit pushes the new file

2. Verify Generated Solution

  1. Navigate to problems/{PROBLEM_ID}/ (use today's problem ID from logs)
  2. Open gpt5-mini.md and verify it contains:
    • Problem title and link
    • "Initial thoughts" section with analysis
    • "Refining the problem" section with complexity notes
    • Python solution in code block
    • Implementation notes

3. Validate Solution Quality

  • Check that the Python code is syntactically valid
  • Verify the solution approach makes sense for the problem
  • Confirm complexity analysis is included

4. Test Schedule (Optional)

  • Wait until 00:01 UTC tomorrow to verify automatic execution
  • Check that workflow runs without manual trigger
  • Verify new solution file appears automatically

Expected Output Structure

problems/
  └── {PROBLEM_ID}/
      └── gpt5-mini.md  ← Should be created with full solution

Troubleshooting

  • Workflow fails at "Run auto-solver": Check OPENAI_API_KEY secret is set correctly
  • "Failed to fetch daily problem": LeetCode API might be temporarily down (retry)
  • "Failed to generate solution": Verify GPT-5-mini model access with your API key
  • No commit pushed: Check workflow logs for file creation errors

Copilot finished work on behalf of jeremymanning November 5, 2025 14:16
@jeremymanning jeremymanning marked this pull request as ready for review November 5, 2025 14:17
Copy link
Member

@jeremymanning jeremymanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@jeremymanning jeremymanning merged commit f5547c3 into main Nov 5, 2025
1 check passed
@jeremymanning jeremymanning deleted the copilot/add-automatic-solver branch November 6, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto-solver?

2 participants