-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask6_5.java
More file actions
25 lines (18 loc) · 929 Bytes
/
Task6_5.java
File metadata and controls
25 lines (18 loc) · 929 Bytes
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
import java.util.Arrays;
import java.util.stream.Stream;
import static utils.LineSeparator.*;
public class Task6_5 {
public static void main(String[] args) {
System.out.print("Your digits: " + Arrays.toString(args) + ";" + lineSeparator());
counterMethod(args);
}
private static boolean helper(int number) {
int[] array = new int[10];
Stream.of(String.valueOf(number).split("")).forEach(digit -> array[Integer.parseInt(digit)]++);
return Arrays.stream(array).filter(digit -> digit == 1).toArray().length == String.valueOf(number).length();
}
private static void counterMethod(String[] arguments) {
System.out.println("Result three-digit number in decimal which is not the same recording figures: ");
Stream.of(arguments).filter(digit -> helper(Integer.parseInt(digit))).filter(length -> length.length()==3).forEach(System.out::println);
}
}