mirror of
https://github.com/Xevion/leetcode.git
synced 2025-12-06 01:15:23 -06:00
Sort questions, move header/separator rows into template, remove hyperlink from ID column
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
This repository contains my solutions to various problems on [LeetCode](https://leetcode.com/).
|
||||
|
||||
Below is the full table containing all the problems I have solved so far. The table is [automatically generated](./.generate/main.py).
|
||||
|
||||
{{ table }}
|
||||
Below is the full table containing all the problems I have solved so far. The table is [automatically generated](./.generate/main.py)automatically generated.
|
||||
| # | Title | Solution | Difficulty |
|
||||
|---| ----- | -------- | ---------- |
|
||||
{{ rows }}
|
||||
|
||||
<sub>
|
||||
Generated on {{ date }}
|
||||
|
||||
@@ -52,10 +52,7 @@ def main():
|
||||
cache_path=ROOT_DIRECTORY / "questions.json", cache_time=60 * 60 * 24
|
||||
)
|
||||
|
||||
table = [
|
||||
"| # | Title | Solution | Difficulty |",
|
||||
"|-|-|-|-|",
|
||||
]
|
||||
table = []
|
||||
|
||||
children = list(SOLUTIONS_DIRECTORY.glob("*/"))
|
||||
logger.debug(f"Found {len(children)} children.")
|
||||
@@ -90,24 +87,24 @@ def main():
|
||||
)
|
||||
|
||||
columns = [
|
||||
f"[{question.id}]({question.url})",
|
||||
question.id,
|
||||
f"[{question.title}]({question.url})",
|
||||
solutions,
|
||||
question.difficulty,
|
||||
]
|
||||
|
||||
row = "| " + " | ".join(map(str, columns)) + " |"
|
||||
table.append((question.id, row))
|
||||
|
||||
table.append(row)
|
||||
|
||||
table = "\n".join(table)
|
||||
table.sort(key=lambda row: row[0])
|
||||
rows = "\n".join(row[1] for row in table)
|
||||
|
||||
with TEMPLATE_PATH.open("r") as template_file:
|
||||
template = Template(template_file.read())
|
||||
|
||||
with (ROOT_DIRECTORY / "README.md").open("w") as readme_file:
|
||||
readme_file.write(
|
||||
template.render(date=datetime.now().strftime("%Y-%m-%d"), table=table)
|
||||
template.render(date=datetime.now().strftime("%Y-%m-%d"), rows=rows)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class QuestionDatabase(object):
|
||||
self.questions = [
|
||||
Question(**question) for question in raw_cache["questions"]
|
||||
]
|
||||
logger.info(f"Loaded {len(self.questions)} questions from cache.")
|
||||
logger.info(f"Loaded {len(self.questions):,} questions from cache.")
|
||||
else:
|
||||
logger.info(f"Cache file {cache_path} does not exist.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user