Skip to content

Commit 8a85e55

Browse files
committed
script added to calculate LOC and mentioned the count in doc.
1 parent b8dfcba commit 8a85e55

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

courseProjectDocs/project-proposal.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## Project Overview
55

6-
< include overview here >
6+
This repository is a curated collection of algorithmic implementations in Python, designed to serve as a reference, learning resource, and toolkit for developers and students alike. It spans a wide range of domains, including blockchain, ciphers, data compressions, data structures, linear algebra, etc.
77

88

99
## Key Quality Metrics
@@ -13,7 +13,20 @@
1313

1414
#### Lines of Code
1515

16-
< include metrics here >
16+
Data Structures Directory:
17+
18+
1. arrays: 871
19+
2. binary tree: 4992
20+
3. disjoint set: 129
21+
4. hashing: 881
22+
5. heap: 1310
23+
6. kd tree: 275
24+
7. linked list: 2611
25+
8. queues: 1246
26+
9. stacks: 1321
27+
10. suffix tree: 165
28+
11. trie: 289
29+
- #### total: 14090
1730

1831
#### Comment Density
1932

data_structures/LOC_calc.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
from collections import defaultdict
3+
4+
def count_python_lines(root_dir):
5+
dir_line_counts = defaultdict(int)
6+
total_lines = 0
7+
8+
for dirpath, _, filenames in os.walk(root_dir):
9+
dir_total = 0
10+
for filename in filenames:
11+
if filename.endswith('.py'):
12+
file_path = os.path.join(dirpath, filename)
13+
try:
14+
with open(file_path, 'r', encoding='utf-8') as f:
15+
lines = sum(1 for line in f if line.strip()) # Count non-empty lines
16+
dir_total += lines
17+
total_lines += lines
18+
except Exception as e:
19+
print(f"Error reading {file_path}: {e}")
20+
dir_line_counts[dirpath] = dir_total
21+
22+
print("\n📁 Lines of Code by Directory:")
23+
for directory, count in sorted(dir_line_counts.items()):
24+
print(f"{directory}: {count} lines")
25+
26+
print(f"\n🧮 Total Lines of Python Code: {total_lines} lines")
27+
28+
# Example usage
29+
if __name__ == "__main__":
30+
count_python_lines("/Users/uzairmukadam/Projects/TheAlgorithms-Python/data_structures") # Replace "." with your target root directory

0 commit comments

Comments
 (0)