Multiple exercises were added to the TypeScript track in this commit.

This commit is contained in:
2025-04-16 21:10:33 +02:00
parent e0d01e1c8d
commit 83ec49cb5b
72 changed files with 81869 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
const originalAlphabet = 'abcdefghijklmnopqrstuvwxyz'
const cipherAlphabet = 'zyxwvutsrqponmlkjihgfedcba'
export function encode(plainText: string): string {
return plainText
.toLowerCase()
.split('')
.map(c => c.match(/\d/) ? c : cipherAlphabet[originalAlphabet.indexOf(c)])
.filter(Boolean)
.map((c, i) => (i + 1) % 5 === 0 ? `${c} ` : c)
.join("")
.trim()
}
export function decode(cipherText: string): string {
return cipherText
.split('')
.map(c => c.match(/\d/) ? c : originalAlphabet[cipherAlphabet.indexOf(c)])
.filter(Boolean)
.join("")
}