Skip to content

Commit d218a2b

Browse files
committed
feat: add leet greek case solution
1 parent 13fabe7 commit d218a2b

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

codewars/leet-greek-case/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Leet Greek Case
2+
3+
## Description
4+
5+
Getting Familiar: LEET: (sometimes written as "1337" or "l33t"), also known as eleet or leetspeak, is another alphabet for the English language that is used mostly on the internet. It uses various combinations of ASCII characters to replace Latinate letters. For example, leet spellings of the word leet include 1337 and l33t; eleet may be spelled 31337 or 3l33t.
6+
7+
GREEK: The Greek alphabet has been used to write the Greek language since the 8th century BC. It was derived from the earlier Phoenician alphabet, and was the first alphabetic script to have distinct letters for vowels as well as consonants. It is the ancestor of the Latin and Cyrillic scripts.Apart from its use in writing the Greek language, both in its ancient and its modern forms, the Greek alphabet today also serves as a source of technical symbols and labels in many domains of mathematics, science and other fields.
8+
9+
Your Task :
10+
11+
```txt
12+
You have to create a function which takes a string as
13+
input and returns it in the form of (L33T+Grεεκ)Case.
14+
Note: The letters which are not being converted in
15+
(L33T+Grεεκ)Case should be returned in the lowercase.
16+
```
17+
18+
(L33T+Grεεκ)Case:
19+
20+
```txt
21+
A=α (Alpha) B=β (Beta) D=δ (Delta)
22+
E=ε (Epsilon) I=ι (Iota) K=κ (Kappa)
23+
N=η (Eta) O=θ (Theta) P=ρ (Rho)
24+
R=π (Pi) T=τ (Tau) U=μ (Mu)
25+
V=υ (Upsilon) W=ω (Omega) X=χ (Chi)
26+
Y=γ (Gamma)
27+
```
28+
29+
Examples:
30+
31+
```txt
32+
CodeWars => cθδεωαπs
33+
Kata => κατα
34+
```

codewars/leet-greek-case/solution.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const GrεεκL33t = (str) => {
2+
const dictionary = {
3+
a: 'α',
4+
b: 'β',
5+
d: 'δ',
6+
e: 'ε',
7+
i: 'ι',
8+
k: 'κ',
9+
n: 'η',
10+
o: 'θ',
11+
p: 'ρ',
12+
r: 'π',
13+
t: 'τ',
14+
u: 'μ',
15+
v: 'υ',
16+
w: 'ω',
17+
x: 'χ',
18+
y: 'γ',
19+
};
20+
21+
return [...str.toLowerCase()]
22+
.map((letter) => dictionary[letter] ?? letter)
23+
.join('');
24+
};
25+
26+
module.exports = GrεεκL33t;
27+
28+
// A=α (Alpha) B=β (Beta) D=δ (Delta)
29+
// E=ε (Epsilon) I=ι (Iota) K=κ (Kappa)
30+
// N=η (Eta) O=θ (Theta) P=ρ (Rho)
31+
// R=π (Pi) T=τ (Tau) U=μ (Mu)
32+
// V=υ (Upsilon) W=ω (Omega) X=χ (Chi)
33+
// Y=γ (Gamma)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const GrεεκL33t = require('./solution');
2+
3+
describe('Leet Greek Case', () => {
4+
const testCases = [
5+
{
6+
input: 'codewars',
7+
output: 'cθδεωαπs',
8+
},
9+
{
10+
input: 'kata',
11+
output: 'κατα',
12+
},
13+
{
14+
input: 'kumite',
15+
output: 'κμmιτε',
16+
},
17+
{
18+
input: 'greekleet',
19+
output: 'gπεεκlεετ',
20+
},
21+
];
22+
23+
it('should return a string type', () => {
24+
expect(typeof GrεεκL33t('hola')).toBe('string');
25+
});
26+
27+
it.each(testCases)('should return $output', (testCase) => {
28+
expect(GrεεκL33t(testCase.input)).toBe(testCase.output);
29+
});
30+
});

0 commit comments

Comments
 (0)