Successfully implemented punctuation preservation for Aristocrat ciphers while maintaining punctuation stripping for Patristocrat ciphers.
encodedLetterCountsKey Logic:
/[A-Z]/), preserve everything else (spaces, punctuation)Updated to handle letter-only indexing while displaying punctuation:
visualIndexFor(): Maps group/char position to visual position in encoded stringletterIndexFromVisual(): Converts visual position to letter-only array indexisLetterAtVisual(): Checks if character at position is a letterhandleLetterChange(): Works with letter-only indices, finds matching encoded lettershandleKeyDown(): Backspace handling with letter-only indiceshandleClear(): Clears only letter positionsisDuplicated(): Checks duplicates using letter-only indicesattemptedOriginalFor(): Maps encoded letters to attempted decryptionattemptedEncodedFor(): Maps attempted letters to encoded lettersdecryptionAttempt now only tracks letters: cipher.encoded.replace(/[^A-Z]/g, '')Comprehensive test suite with 8 tests:
All tests pass! ✅
cipher.encoded: Full string with letters, spaces, and punctuation (aristocrat) or letters + spaces only (patristocrat)decryptionAttempt[]: Array of only letters (no punctuation or spaces)Input: "Hello, World!"
Aristocrat Mode:
cipher.encoded: "KHOOR, ZRUOG!" (letters encoded, punctuation preserved)decryptionAttempt: ["", "", "", "", "", "", "", "", "", ""] (10 letters only)K H O O R , W R U O G ! with inputs only under lettersPatristocrat Mode:
cipher.encoded: "KHOOR ZRUOG" (punctuation stripped, grouped)decryptionAttempt: ["", "", "", "", "", "", "", "", "", ""] (same 10 letters)KHOOR ZRUOG with inputs under all charactersRun tests:
deno test substitutionCipher.test.ts
All 8 tests pass with type checking enabled.