|
1 | | -# import os |
2 | | -# import re |
3 | | -# import requests |
4 | | - |
5 | | -# def extract_problem_info(file_path): |
6 | | -# match = re.match(r"(\d+)-([a-z0-9-]+)\.py", os.path.basename(file_path)) |
7 | | -# if match: |
8 | | -# problem_number, slug = match.groups() |
9 | | -# return int(problem_number), slug, f"[{slug.replace('-', ' ').title()}](https://leetcode.com/problems/{slug}/description/)" |
10 | | -# return None, None, None |
11 | | - |
12 | | -# def get_problem_stats(slug): |
13 | | -# url = "https://leetcode.com/graphql" |
14 | | -# query = """ |
15 | | -# query getQuestionStats($titleSlug: String!) { |
16 | | -# question(titleSlug: $titleSlug) { |
17 | | -# difficulty |
18 | | -# topicTags { |
19 | | -# name |
20 | | -# } |
21 | | -# } |
22 | | -# } |
23 | | -# """ |
24 | | -# response = requests.post(url, json={"query": query, "variables": {"titleSlug": slug}}) |
25 | | -# try: |
26 | | -# data = response.json()["data"]["question"] |
27 | | -# difficulty = data["difficulty"] |
28 | | -# tags = ", ".join(tag["name"] for tag in data["topicTags"]) |
29 | | -# return difficulty, tags |
30 | | -# except (KeyError, TypeError): |
31 | | -# return "Unknown", "Unknown" |
32 | | - |
33 | | -# def build_readme(): |
34 | | -# topics = [d for d in os.listdir('.') if os.path.isdir(d)] |
35 | | -# problem_entries = [] |
36 | | - |
37 | | -# for topic in topics: |
38 | | -# for file in os.listdir(topic): |
39 | | -# if file.endswith(".py"): |
40 | | -# problem_number, slug, problem_title = extract_problem_info(file) |
41 | | -# if problem_number: |
42 | | -# difficulty, tags, accepted, submissions, acceptance_rate = get_problem_stats(slug) |
43 | | -# problem_entries.append((problem_number, problem_title, f"[Python](./{topic}/{file})", difficulty, tags, accepted, submissions, acceptance_rate)) |
44 | | - |
45 | | -# problem_entries.sort() |
46 | | - |
47 | | -# table_header = "| # | Title | Solution | Tags | Difficulty |\n|---| ----- | -------- | ---------- | ---- | -------- | ----------- | --------------- |" |
48 | | -# table_rows = [] |
49 | | - |
50 | | -# for number, title, solution, tags, difficulty in problem_entries: |
51 | | -# table_rows.append(f"|{number:04d}|{title}|{solution}| {tags} | {difficulty} | ") |
52 | | - |
53 | | -# table_content = "\n".join([table_header] + table_rows) |
54 | | -# readme_content = f"""# 📌 LeetCode Solutions - Coding Every Day Until I Get A Job |
55 | | - |
56 | | -# Welcome to my LeetCode solutions repository! 🚀 Here, I solve coding challenges every day to improve my problem-solving skills and prepare for technical interviews. |
57 | | - |
58 | | -# ## 🔥 Problem List |
59 | | - |
60 | | -# {table_content} |
61 | | - |
62 | | -# ## 🚀 Keep Coding & Stay Motivated! |
63 | | - |
64 | | -# Happy coding! 😊""" |
65 | | - |
66 | | -# with open("README.md", "w", encoding="utf-8") as f: |
67 | | -# f.write(readme_content) |
68 | | - |
69 | | -# if __name__ == "__main__": |
70 | | -# build_readme() |
71 | | -# print("README.md has been updated!") |
72 | | - |
73 | 1 | import os |
74 | 2 | import re |
75 | 3 | import requests |
|
0 commit comments