Skip to content

Commit 369788d

Browse files
author
Saiprashanth Pulisetti
committed
refactor(ciphers): improve variable naming for clarity in columnar transposition cipher
1 parent 5ea264a commit 369788d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ciphers/columnar_transposition.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _normalize_key(key: str) -> str:
4040
def _column_order(key: str) -> list[int]:
4141
# Stable sort by character then original index to handle duplicates
4242
indexed = list(enumerate(key))
43-
return [i for i, _ in sorted(indexed, key=lambda t: (t[1], t[0]))]
43+
return [i for i, _ in sorted(indexed, key=lambda indexed_pair: (indexed_pair[1], indexed_pair[0]))]
4444

4545

4646
def encrypt(plaintext: str, key: str) -> str:
@@ -85,9 +85,9 @@ def decrypt(ciphertext: str, key: str) -> str:
8585
return ciphertext
8686

8787
order = _column_order(k)
88-
L = len(ciphertext)
89-
rows = (L + cols - 1) // cols
90-
r = L % cols
88+
text_len = len(ciphertext)
89+
rows = (text_len + cols - 1) // cols
90+
r = text_len % cols
9191

9292
# Column lengths based on ragged last row (no padding during encryption)
9393
col_lengths: list[int] = []

0 commit comments

Comments
 (0)