Skip to content
Closed

LOC #12953

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions courseProjectDocs/project-proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Project Proposal


## Project Overview

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.


## Key Quality Metrics


### Code Structure

#### Lines of Code

Data Structures Directory:

1. arrays: 871
2. binary tree: 4992
3. disjoint set: 129
4. hashing: 881
5. heap: 1310
6. kd tree: 275
7. linked list: 2611
8. queues: 1246
9. stacks: 1321
10. suffix tree: 165
11. trie: 289
- #### total: 14090

#### Comment Density

< include metrics here >

#### Cyclomatic Complexity

< include metrics here >

### Testability

#### Number of Unit Test Cases

< include metrics here >

#### Test Coverage

< include metrics here >
30 changes: 30 additions & 0 deletions data_structures/LOC_calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os

Check failure on line 1 in data_structures/LOC_calc.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N999)

data_structures/LOC_calc.py:1:1: N999 Invalid module name: 'LOC_calc'
from collections import defaultdict

Check failure on line 2 in data_structures/LOC_calc.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

data_structures/LOC_calc.py:1:1: I001 Import block is un-sorted or un-formatted

def count_python_lines(root_dir):
dir_line_counts = defaultdict(int)
total_lines = 0

for dirpath, _, filenames in os.walk(root_dir):
dir_total = 0
for filename in filenames:
if filename.endswith('.py'):
file_path = os.path.join(dirpath, filename)
try:
with open(file_path, 'r', encoding='utf-8') as f:

Check failure on line 14 in data_structures/LOC_calc.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (UP015)

data_structures/LOC_calc.py:14:42: UP015 Unnecessary mode argument
lines = sum(1 for line in f if line.strip()) # Count non-empty lines

Check failure on line 15 in data_structures/LOC_calc.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

data_structures/LOC_calc.py:15:89: E501 Line too long (93 > 88)
dir_total += lines
total_lines += lines
except Exception as e:

Check failure on line 18 in data_structures/LOC_calc.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (BLE001)

data_structures/LOC_calc.py:18:24: BLE001 Do not catch blind exception: `Exception`
print(f"Error reading {file_path}: {e}")
dir_line_counts[dirpath] = dir_total

print("\n📁 Lines of Code by Directory:")
for directory, count in sorted(dir_line_counts.items()):
print(f"{directory}: {count} lines")

print(f"\n🧮 Total Lines of Python Code: {total_lines} lines")

# Example usage
if __name__ == "__main__":
count_python_lines("/Users/uzairmukadam/Projects/TheAlgorithms-Python/data_structures") # Replace "." with your target root directory

Check failure on line 30 in data_structures/LOC_calc.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

data_structures/LOC_calc.py:30:89: E501 Line too long (138 > 88)
Loading