Skip to content

Commit 4786c6e

Browse files
committed
Add AlphabetWar
1 parent aee0ae7 commit 4786c6e

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/_AlphabetWar/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Alphabet Wars
2+
3+
## URL
4+
5+
![Alphabet Wars](https://www.codewars.com/kata/59377c53e66267c8f6000027/train/javascript)
6+
7+
## Introduction
8+
9+
There is a war and nobody knows - the alphabet war!
10+
There are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began.
11+
12+
Task
13+
Write a function that accepts fight string consists of only small letters and return who wins the fight. When the left side wins return Left side wins!, when the right side wins return Right side wins!, in other case return Let's fight again!.
14+
15+
The left side letters and their power:
16+
17+
```javascript
18+
w - 4
19+
p - 3
20+
b - 2
21+
s - 1
22+
```
23+
24+
The right side letters and their power:
25+
26+
```javascript
27+
m - 4
28+
q - 3
29+
d - 2
30+
z - 1
31+
```
32+
33+
The other letters don't have power and are only victims.
34+
35+
Example
36+
alphabetWar("z"); //=> Right side wins!
37+
alphabetWar("zdqmwpbs"); //=> Let's fight again!
38+
alphabetWar("zzzzs"); //=> Right side wins!
39+
alphabetWar("wwwwwwz"); //=> Left side wins!
40+
Alphabet war Collection
41+
Alphavet war
42+
Alphabet war - airstrike - letters massacre
43+
Alphabet wars - reinforces massacre
44+
Alphabet wars - nuclear strike
45+
Alphabet war - Wo lo loooooo priests join the war

src/_AlphabetWar/alphabet-wars.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function alphabetWar(fight)
2+
{
3+
return "Let's fight again!";
4+
}

tests/alphabet-wars.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Test.assertEquals( alphabetWar("z") , "Right side wins!" );
2+
// Test.assertEquals( alphabetWar("zdqmwpbs") , "Let's fight again!" );
3+
// Test.assertEquals( alphabetWar("zzzzs"), "Right side wins!" );
4+
// Test.assertEquals( alphabetWar("wwwwww"), "Left side wins!" );

0 commit comments

Comments
 (0)