-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathThreeNumbers.java
More file actions
50 lines (41 loc) · 1.16 KB
/
Copy pathThreeNumbers.java
File metadata and controls
50 lines (41 loc) · 1.16 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.*;
import java.io.*;
class Main {
public static String StringChallenge(String str) {
// code goes here
String[] words = str.split(" ");
int counter = 0;
boolean lever = true;
String output;
for(String s : words){
counter = 0;
ArrayList<Character> digits = new ArrayList<Character>();
for(int i = 0; i< s.length() ; i++){
if(Character.isDigit(s.charAt(i))){
counter++;
digits.add(s.charAt(i));
}
if(i<s.length()-2){
if(Character.isDigit(s.charAt(i)) && Character.isDigit(s.charAt(i+1)) && Character.isDigit(s.charAt(i+2))){
lever = false;
}
}
}
Set<Character> set = new HashSet<Character>(digits);
if(set.size()<3){
lever=false;
}
}
if(lever){
output = "true";
}else{
output = "false";
}
return output;
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(StringChallenge(s.nextLine()));
}
}