Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kata/8-kyu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
- [Is it even?](is-it-even "555a67db74814aa4ee0001b5")
- [Is n divisible by x and y?](is-n-divisible-by-x-and-y "5545f109004975ea66000086")
- [Is the string uppercase?](is-the-string-uppercase "56cd44e1aa4ac7879200010b")
- [Is there a vowel in there?](is-there-a-vowel-in-there "57cff961eca260b71900008f")
- [Is your period late?](is-your-period-late "578a8a01e9fd1549e50001f1")
- [Jenny's secret message](jennys-secret-message "55225023e1be1ec8bc000390")
- [Kata Example Twist](kata-example-twist "525c1a07bb6dda6944000031")
Expand Down
8 changes: 8 additions & 0 deletions kata/8-kyu/is-there-a-vowel-in-there/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# [Is there a vowel in there?](https://www.codewars.com/kata/is-there-a-vowel-in-there "https://www.codewars.com/kata/57cff961eca260b71900008f")

Given an array of numbers, check if any of the numbers are the character codes for lower case vowels (`a, e, i, o, u`).

If they are, change the array value to a string of that vowel.

`input [100,100,116,105,117,121]=>[100,100,116,"i","u",121] output`
Return the resulting array.
7 changes: 7 additions & 0 deletions kata/8-kyu/is-there-a-vowel-in-there/main/VowelMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import java.util.List;

interface VowelMapper {
static List<Object> isVow(List<Integer> a) {
return a.stream().map(i -> (Object) ("aeiou".indexOf(i) < 0 ? i : ((char) i.intValue()) + "")).toList();
}
}
28 changes: 28 additions & 0 deletions kata/8-kyu/is-there-a-vowel-in-there/test/VowelMapperTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class VowelMapperTest {
private static Stream<Arguments> testData() {
return Stream.of(
Arguments.of(
List.of(118, 117, 120, 121, 117, 98, 122, 97, 120, 106, 104, 116, 113, 114, 113, 120, 106),
List.of(118, "u", 120, 121, "u", 98, 122, "a", 120, 106, 104, 116, 113, 114, 113, 120, 106)
),
Arguments.of(
List.of(101, 121, 110, 113, 113, 103, 121, 121, 101, 107, 103),
List.of("e", 121, 110, 113, 113, 103, 121, 121, "e", 107, 103)
)
);
}

@ParameterizedTest
@MethodSource("testData")
void sample(List<Integer> input, List<Object> expected) {
assertEquals(expected, VowelMapper.isVow(input));
}
}