-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagnets.java
More file actions
28 lines (24 loc) · 813 Bytes
/
Magnets.java
File metadata and controls
28 lines (24 loc) · 813 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
/**
* Created by MalhotR1 on 05/20/2018.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Magnets {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int T = Integer.parseInt(br.readLine().trim());
char[] arr = new char[2*T];
for (int t = 0; t < T; t++) {
String in = br.readLine().trim();
arr[2*t] = in.charAt(0);
arr[2*t + 1] = in.charAt(1);
}
int total = 1;
for (int i = 0; i < arr.length - 1; i++) {
if (arr[i] == arr[i+1]) total++;
}
System.out.println(total);
}
}
}