-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay6.java
27 lines (22 loc) · 852 Bytes
/
Day6.java
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
import java.util.Scanner;
public class Day6 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testCases = scanner.nextInt();
scanner.nextLine();
while (testCases-- > 0) {
String string = scanner.nextLine();
String evenIndexedString = skippedIndices(string, 0);
String oddIndexedString = skippedIndices(string, 1);
System.out.println(evenIndexedString + ' ' + oddIndexedString);
}
scanner.close();
}
private static String skippedIndices(String string, int startIndex) {
StringBuilder result = new StringBuilder();
for (int index = startIndex ; index < string.length() ; index += 2) {
result.append(string.charAt(index));
}
return result.toString();
}
}