File tree Expand file tree Collapse file tree 4 files changed +2304
-0
lines changed Expand file tree Collapse file tree 4 files changed +2304
-0
lines changed Original file line number Diff line number Diff line change 1+ name : run-python
2+
3+ on : workflow_dispatch
4+
5+ jobs :
6+ build :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - uses : actions/checkout@v3
10+ - uses : actions/setup-python@v4
11+ with :
12+ python-version : ' 3.x'
13+ architecture : ' x64'
14+ - run : |
15+ python -m pip install --upgrade pip
16+ pip install requests
17+ - run : |
18+ python cron/difficulty.py
Original file line number Diff line number Diff line change 2222npm-debug.log *
2323yarn-debug.log *
2424yarn-error.log *
25+
26+ __pycache__
Original file line number Diff line number Diff line change 1+ import requests
2+ from urllib .parse import urlparse
3+ from questions import questions
4+
5+ query = '''query questionData($titleSlug: String!) {
6+ question(titleSlug: $titleSlug) {
7+ difficulty
8+ }
9+ }
10+ '''
11+
12+ for question in questions :
13+ p = urlparse (question ["url" ])
14+ title_slug = p .path .rstrip ('/' ).split ('/' )[- 1 ]
15+ our_difficulty = question ["difficulty" ]
16+ variables = {"titleSlug" : title_slug }
17+
18+ response = requests .post ("https://leetcode.com/graphql" ,
19+ json = {"query" : query , "variables" : variables }
20+ )
21+
22+ their_difficulty = response .json ()["data" ]["question" ]["difficulty" ]
23+
24+ if their_difficulty != our_difficulty :
25+ print (f'{ question ["name" ]} : { our_difficulty } -> { their_difficulty } ' )
26+
27+ print ("Finished checking all questions" )
You can’t perform that action at this time.
0 commit comments