Skip to content

Commit a7ba96e

Browse files
* docs: kata description * feat: kata/is-there-a-vowel-in-there --------- Co-authored-by: ParanoidUser <[email protected]>
1 parent 857fede commit a7ba96e

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

kata/8-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
- [Is it even?](is-it-even "555a67db74814aa4ee0001b5")
129129
- [Is n divisible by x and y?](is-n-divisible-by-x-and-y "5545f109004975ea66000086")
130130
- [Is the string uppercase?](is-the-string-uppercase "56cd44e1aa4ac7879200010b")
131+
- [Is there a vowel in there?](is-there-a-vowel-in-there "57cff961eca260b71900008f")
131132
- [Is your period late?](is-your-period-late "578a8a01e9fd1549e50001f1")
132133
- [Jenny's secret message](jennys-secret-message "55225023e1be1ec8bc000390")
133134
- [Kata Example Twist](kata-example-twist "525c1a07bb6dda6944000031")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# [Is there a vowel in there?](https://www.codewars.com/kata/is-there-a-vowel-in-there "https://www.codewars.com/kata/57cff961eca260b71900008f")
2+
3+
Given an array of numbers, check if any of the numbers are the character codes for lower case vowels (`a, e, i, o, u`).
4+
5+
If they are, change the array value to a string of that vowel.
6+
7+
`input [100,100,116,105,117,121]=>[100,100,116,"i","u",121] output`
8+
Return the resulting array.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java.util.List;
2+
3+
interface VowelMapper {
4+
static List<Object> isVow(List<Integer> a) {
5+
return a.stream().map(i -> (Object) ("aeiou".indexOf(i) < 0 ? i : ((char) i.intValue()) + "")).toList();
6+
}
7+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import java.util.List;
4+
import java.util.stream.Stream;
5+
import org.junit.jupiter.params.ParameterizedTest;
6+
import org.junit.jupiter.params.provider.Arguments;
7+
import org.junit.jupiter.params.provider.MethodSource;
8+
9+
class VowelMapperTest {
10+
private static Stream<Arguments> testData() {
11+
return Stream.of(
12+
Arguments.of(
13+
List.of(118, 117, 120, 121, 117, 98, 122, 97, 120, 106, 104, 116, 113, 114, 113, 120, 106),
14+
List.of(118, "u", 120, 121, "u", 98, 122, "a", 120, 106, 104, 116, 113, 114, 113, 120, 106)
15+
),
16+
Arguments.of(
17+
List.of(101, 121, 110, 113, 113, 103, 121, 121, 101, 107, 103),
18+
List.of("e", 121, 110, 113, 113, 103, 121, 121, "e", 107, 103)
19+
)
20+
);
21+
}
22+
23+
@ParameterizedTest
24+
@MethodSource("testData")
25+
void sample(List<Integer> input, List<Object> expected) {
26+
assertEquals(expected, VowelMapper.isVow(input));
27+
}
28+
}

0 commit comments

Comments
 (0)