I'm having issues with debugging the texture analysis on Kattis. I'm able to finish every test case i can imagine but yet the last test case fails. Does anyone have any idea what might be causing the last test case to fail?
public static void main(String[] args) throws Exception {
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter dc = new BufferedWriter(new OutputStreamWriter(System.out));
int numOfLines = 1;
for (;;) {
String inputLine = sc.readLine();
if (inputLine.equals("END"))
break;
else if (!inputLine.contains(".")) {
dc.write(numOfLines++ + " EVEN\n");
} else {
//Next two lines creates an array out of the characters in a single line
String[] tempArray = inputLine.split("");
ArrayList<String> charArray = new ArrayList<String>(Arrays.asList(tempArray));
//Next block of code finds all elements where an asterix has been found and puts them in the allIndexes array
//If the code is even, the elements will for example be on 0, 2, 4, 6
//If the code is uneven, the elements will for example be on 0, 1, 5, 8
String str = "*";
List<Integer> allIndexes =
IntStream.range(0, charArray.size()).boxed()
.filter(j -> charArray.get(j).equals(str))
.collect(Collectors.toList());
ArrayList<Integer> duplicateList = new ArrayList<>();
//For-loop, is used to normalize numbers
//An even array of 0,2,4,6 turns into 2,2,2,2
//An uneven array of 0,2,6,8 turns into 2,4,2,2
//This means we can easily see where the uneven number is
for (int j = 0; j < allIndexes.size(); j++) {
if(j < allIndexes.size() - 1)
duplicateList.add(allIndexes.get(j + 1) - allIndexes.get(j));
}
Boolean isArrayUneven = false;
//Here we check for uneven numbers in the array
//If one is found then isArrayUneven turns true.
for (int i = 1; i < duplicateList.size();i++) {
if (duplicateList.get(0) != duplicateList.get(i)) {
isArrayUneven = true;
}
}
if (isArrayUneven ==true ) {
dc.write(numOfLines++ + " NOT EVEN" + "\n");
}
else{
dc.write(numOfLines++ + " EVEN" + "\n");
}
}
}
dc.close();
sc.close();
}