-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_12289_OneTwoThree.java
More file actions
35 lines (27 loc) · 850 Bytes
/
_12289_OneTwoThree.java
File metadata and controls
35 lines (27 loc) · 850 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
26
27
28
29
30
31
32
33
34
35
package io.github.tahanima.uva;
import java.util.Scanner;
/**
* @author tahanima
*/
public class _12289_OneTwoThree {
public static boolean isOne(String word) {
String one = "one";
int noOfMismatch = 0;
for (int i = 0; i < 3; i++) {
if (word.charAt(i) != one.charAt(i))
noOfMismatch++;
}
return noOfMismatch <= 1;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
StringBuilder stringBuilder = new StringBuilder();
int testCases = scanner.nextInt();
while (testCases-- > 0) {
String word = scanner.next();
stringBuilder.append(word.length() == 5 ? 3 : (isOne(word) ? 1 : 2))
.append("\n");
}
System.out.print(stringBuilder);
}
}