Skip to content

Commit 7f79f3b

Browse files
authored
feat: migrate rules to .cursor (#70)
- migrate rules to .cursor - add problem same_tree
1 parent f9b0dd2 commit 7f79f3b

26 files changed

+585
-229
lines changed

.amazonq/plans/check_problem_lists.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

.amazonq/plans/export_tags.py

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# TODO: temporary use only while completing ongoing list
2+
3+
import sys
4+
from pathlib import Path
5+
6+
# Import the problem lists
7+
sys.path.append(str(Path(__file__).parent.parent.parent))
8+
from problem_lists import available_lists
9+
from problem_lists.utils import get_existing_problems
10+
11+
12+
def check_problem_list(tag_name, problem_tuples, existing_problems):
13+
"""Check how many problems from a list are available."""
14+
problem_numbers = {num for num, _ in problem_tuples}
15+
have = problem_numbers & existing_problems
16+
missing = problem_numbers - existing_problems
17+
18+
print(f"\n=== {tag_name.upper()} ===")
19+
print(f"Total problems: {len(problem_numbers)}")
20+
print(f"Problems you have: {len(have)} ({len(have)/len(problem_numbers)*100:.1f}%)")
21+
print(f"Problems missing: {len(missing)} ({len(missing)/len(problem_numbers)*100:.1f}%)")
22+
23+
if missing:
24+
print(f"Missing problems: {sorted(missing)}")
25+
26+
return have, missing
27+
28+
29+
def check_problem_lists(tag_names=None):
30+
"""Check problem lists for available problems."""
31+
if tag_names is None:
32+
tag_names = list(available_lists.keys())
33+
34+
existing = get_existing_problems()
35+
print(f"Total existing problems in JSON: {len(existing)}")
36+
37+
results = {}
38+
39+
# Check each specified list
40+
for tag_name, problem_tuples in available_lists.items():
41+
if tag_name in tag_names:
42+
have, missing = check_problem_list(tag_name, problem_tuples, existing)
43+
results[tag_name] = {"have": have, "missing": missing, "total": len(problem_tuples)}
44+
45+
# Summary
46+
print("\n=== SUMMARY ===")
47+
for tag_name, result in results.items():
48+
total = result["total"]
49+
have_count = len(result["have"])
50+
percentage = have_count / total * 100
51+
print(f"{tag_name}: {have_count}/{total} ({percentage:.1f}%)")
52+
53+
return results
54+
55+
56+
def main():
57+
check_problem_lists()
58+
59+
60+
if __name__ == "__main__":
61+
main()

.cursor/.dev/next_problem.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# TODO: temporary use only while completing ongoing list
2+
3+
import sys
4+
from pathlib import Path
5+
6+
# Import the problem lists
7+
sys.path.append(str(Path(__file__).parent.parent.parent))
8+
from problem_lists import available_lists
9+
from problem_lists.utils import get_existing_problems
10+
11+
12+
def get_next_problem(tag_names=None):
13+
"""Get the next problem to work on from the list with the lowest missing problems."""
14+
if tag_names is None:
15+
tag_names = list(available_lists.keys())
16+
17+
existing_problems = get_existing_problems()
18+
19+
# Find the list with the lowest missing problems
20+
best_list = None
21+
min_missing = float("inf")
22+
missing_problems = []
23+
24+
for tag_name, problem_tuples in available_lists.items():
25+
if tag_name in tag_names:
26+
problem_numbers = {num for num, _ in problem_tuples}
27+
missing = problem_numbers - existing_problems
28+
missing_count = len(missing)
29+
30+
if missing_count > 0 and missing_count < min_missing:
31+
min_missing = missing_count
32+
best_list = tag_name
33+
missing_problems = sorted(missing)
34+
35+
if not missing_problems:
36+
print("No missing problems found in any of the specified lists!")
37+
return None
38+
39+
# Get the first missing problem from the best list
40+
next_problem_number = missing_problems[0]
41+
42+
# Find the problem name
43+
problem_tuples = available_lists[best_list]
44+
problem_name = None
45+
for num, name in problem_tuples:
46+
if num == next_problem_number:
47+
problem_name = name
48+
break
49+
50+
result = {
51+
"tag_name": best_list,
52+
"problem_number": next_problem_number,
53+
"problem_name": problem_name,
54+
"missing_count": min_missing,
55+
"total_in_list": len(available_lists[best_list]),
56+
}
57+
58+
return result
59+
60+
61+
def main():
62+
next_problem = get_next_problem()
63+
if next_problem:
64+
completed = next_problem["total_in_list"] - next_problem["missing_count"]
65+
total = next_problem["total_in_list"]
66+
percentage = completed / total * 100
67+
68+
print("\n🎯 Next problem to work on:")
69+
print(f" Problem #{next_problem['problem_number']} - {next_problem['problem_name']}")
70+
print(f" Tag: {next_problem['tag_name']}")
71+
print(f" Progress: {completed}/{total} ({percentage:.1f}%)")
72+
73+
74+
if __name__ == "__main__":
75+
main()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from . import algo_master_75, blind_75, neetcode_150
2+
3+
available_lists = {
4+
neetcode_150.tag_name: neetcode_150.problems_list,
5+
algo_master_75.tag_name: algo_master_75.problems_list,
6+
blind_75.tag_name: blind_75.problem_list,
7+
}

.amazonq/plans/algo_master_75_tuples.py renamed to .cursor/.dev/problem_lists/algo_master_75.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
algo_master_75_tuples = [
1+
tag_name = "algo-master-75"
2+
3+
problems_list = [
24
(2, "Add Two Numbers"),
35
(3, "Longest Substring Without Repeating Characters"),
46
(4, "Median of Two Sorted Arrays"),

.amazonq/plans/blind_75_tuples.py renamed to .cursor/.dev/problem_lists/blind_75.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
blind_75_tuples = [
1+
tag_name = "blind-75"
2+
3+
problem_list = [
24
(1, "Two Sum"),
35
(3, "Longest Substring Without Repeating Characters"),
46
(5, "Longest Palindromic Substring"),

.amazonq/plans/neetcode_150_tuples.py renamed to .cursor/.dev/problem_lists/neetcode_150.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
neetcode_150_tuples = [
1+
tag_name = "neetcode-150"
2+
3+
problems_list = [
24
(1, "Two Sum"),
35
(2, "Add Two Numbers"),
46
(3, "Longest Substring Without Repeating Characters"),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Shared utilities for problem list management."""
2+
3+
from leetcode_py.cli.utils.problem_finder import _build_problem_number_cache
4+
5+
6+
def get_existing_problems():
7+
"""Get problem numbers from existing JSON files."""
8+
cache = _build_problem_number_cache()
9+
return set(cache.keys())

0 commit comments

Comments
 (0)