Skip to content

Commit 2da96db

Browse files
add python function for creating a new problem note
1 parent 35b983e commit 2da96db

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

create_note.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
import os
3+
4+
# Load problem details
5+
with open("problem_details.json", "r") as f:
6+
problem_details = json.load(f)
7+
8+
# Define paths
9+
template_path = "problems/template.md"
10+
problem_dir = f"problems/{problem_details['questionId']}"
11+
github_username = os.getenv('GITHUB_USERNAME')
12+
problem_file = f"{problem_dir}/{github_username}.md" # Replace with actual username
13+
14+
# Create problem directory if it doesn't exist
15+
os.makedirs(problem_dir, exist_ok=True)
16+
17+
# Read template content
18+
with open(template_path, "r") as f:
19+
template_content = f.read()
20+
21+
# Customize template with problem details
22+
note_content = template_content.replace("<NUMBER>", problem_details['questionId'])
23+
note_content = note_content.replace("<TITLE>", problem_details['title'])
24+
note_content = note_content.replace("<LINK TO DESCRIPTION>", problem_details['link'])
25+
26+
# Write customized note to new file
27+
with open(problem_file, "w") as f:
28+
f.write(note_content)

0 commit comments

Comments
 (0)