-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomCustomsSixOne.java
More file actions
38 lines (35 loc) · 1.13 KB
/
CustomCustomsSixOne.java
File metadata and controls
38 lines (35 loc) · 1.13 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
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
public class CustomCustomsSixOne {
public static void main(String[] args) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("customcustoms.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int totalCount = 0;
try {
String input = reader.readLine();
Set<Character> questions = new HashSet<>();
while (input != null) {
if (input.equals("")) {
totalCount += questions.size();
questions.clear();
} else {
for (int idx = 0; idx < input.length(); idx++) {
questions.add(input.charAt(idx));
}
}
input = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(totalCount);
}
}