Skip to content

Commit 0331884

Browse files
* docs: kata description * feat: kata/numbers-to-letters --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent bd3039d commit 0331884

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

kata/7-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
- [Number-Star ladder](number-star-ladder "5631213916d70a0979000066")
367367
- [Number to digit tiers](number-to-digit-tiers "586bca7fa44cfc833e00005c")
368368
- [Numbers in strings](numbers-in-strings "59dd2c38f703c4ae5e000014")
369+
- [Numbers to Letters](numbers-to-letters "57ebaa8f7b45ef590c00000c")
369370
- [Numbers Which Sum of Powers of Its Digits Is The Same Number](numbers-which-sum-of-powers-of-its-digits-is-the-same-number "560a4962c0cc5c2a16000068")
370371
- [Numbers with d occurrences of digit d](numbers-with-d-occurences-of-digit-d "5a40fc7ce1ce0e34440000a3")
371372
- [Numbers with this digit inside](numbers-with-this-digit-inside "57ad85bb7cb1f3ae7c000039")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# [Numbers to Letters](https://www.codewars.com/kata/numbers-to-letters "https://www.codewars.com/kata/57ebaa8f7b45ef590c00000c")
2+
3+
Given an array of numbers (in string format), you must return a string. The numbers correspond to the letters of the alphabet in reverse
4+
order: a=26, z=1 etc. You should also account for `'!'`, `'?'` and `' '` that are represented by '27', '28' and '29' respectively.
5+
6+
All inputs will be valid.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import static java.util.stream.Stream.of;
2+
import static java.util.stream.Collectors.joining;
3+
4+
interface Kata{
5+
static String switcher(String[] arr){
6+
return of(arr).map(n -> "_zyxwvutsrqponmlkjihgfedcba!? ".charAt(Integer.parseInt(n)) + "").collect(joining());
7+
}
8+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class SwitcherTest {
7+
@ParameterizedTest
8+
@CsvSource(delimiter = '|', textBlock = """
9+
12 | o
10+
4,24 | wc
11+
24,12,23,22,4,26,9,8 | codewars
12+
25,7,8,4,14,23,8,25,23,29,16,16,4 | btswmdsbd kkw
13+
12,28,25,21,25,7,11,22,15 | o?bfbtpel
14+
""")
15+
void sample(String arr, String expected) {
16+
assertEquals(expected, Kata.switcher(arr.split(",")));
17+
}
18+
}

0 commit comments

Comments
 (0)