Good day.
The grading system is incorrectly grading my solution. It says if I enter the numbers 2, 3 and 1 I should get 2. Which is incorrect.
Thanks.
package en.codegym.task.jdk13.task04.task0441;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.ArrayList;
/*
Somewhere in the middle
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < 3; i++) {
list.add(Integer.parseInt(reader.readLine()));
}
for (int i = 0; i < list.size() ;) {
for (int j = 1; j < list.size(); j++) {
if (list.get(i) != list.get(j) && list.get(j) != list.get(list.size() - 1) && list.get(i) != list.get(list.size() - 1)) {
System.out.println(list.get(j));
}
else if (list.get(i) == list.get(j) && list.get(j) == list.get(list.size() - 1)) {
int random = list.get(new Random().nextInt(list.size()));
System.out.println(random);
}
else if (list.get(i) == list.get(j) || list.get(j) == list.get(list.size() - 1) || list.get(i) == list.get(list.size() - 1)) {
if (list.get(i) == list.get(j)) {
System.out.println(list.get(i));
}
else if (list.get(j) == list.get(list.size() - 1)) {
System.out.println(list.get(j));
}
else if (list.get(i) == list.get(list.size() - 1)) {
System.out.println(list.get(list.size() - 1));
}
}
break;
}
break;
}
}
}