-
Notifications
You must be signed in to change notification settings - Fork 0
/
CWars.java
30 lines (24 loc) · 900 Bytes
/
CWars.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.smlnskgmail.jaman.codewarsjava.kyu7;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
// https://www.codewars.com/kata/55968ab32cf633c3f8000008
public class CWars {
private final String input;
public CWars(String input) {
this.input = input;
}
public String solution() {
String[] words = input.split(" ");
int length = words.length - 1;
return IntStream
.rangeClosed(0, length)
.mapToObj(i -> {
String word = words[i];
char firstSymbol = Character.toUpperCase(word.charAt(0));
return i != length
? String.format("%s.", firstSymbol)
: String.format("%s%s", firstSymbol, word.substring(1));
})
.collect(Collectors.joining());
}
}