|
|
@@ -4,21 +4,19 @@ import java.util.Arrays;
|
|
4
|
4
|
import java.util.List;
|
|
5
|
5
|
import java.util.stream.Collectors;
|
|
6
|
6
|
|
|
7
|
|
-public class Series {
|
|
|
7
|
+class Series {
|
|
8
|
8
|
|
|
9
|
9
|
private final int digitsSize;
|
|
10
|
10
|
private List<Integer> digits;
|
|
11
|
11
|
|
|
12
|
|
- public Series(String string) {
|
|
13
|
|
- this.digits = Arrays
|
|
14
|
|
- .asList(string.split(("")))
|
|
15
|
|
- .stream()
|
|
16
|
|
- .map(digit -> Integer.parseInt(digit))
|
|
17
|
|
- .collect(Collectors.toList());
|
|
|
12
|
+ Series(String string) {
|
|
|
13
|
+ this.digits = Arrays.stream(string.split(""))
|
|
|
14
|
+ .map(Integer::parseInt)
|
|
|
15
|
+ .collect(Collectors.toList());
|
|
18
|
16
|
this.digitsSize = this.digits.size();
|
|
19
|
17
|
}
|
|
20
|
18
|
|
|
21
|
|
- public List<List<Integer>> slices(int num) {
|
|
|
19
|
+ List<List<Integer>> slices(int num) {
|
|
22
|
20
|
if (num > this.digitsSize) {
|
|
23
|
21
|
throw new IllegalArgumentException("Slice size is too big.");
|
|
24
|
22
|
}
|
|
|
@@ -32,7 +30,7 @@ public class Series {
|
|
32
|
30
|
return result;
|
|
33
|
31
|
}
|
|
34
|
32
|
|
|
35
|
|
- public List<Integer> getDigits() {
|
|
|
33
|
+ List<Integer> getDigits() {
|
|
36
|
34
|
return digits;
|
|
37
|
35
|
}
|
|
38
|
36
|
|