import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; class DayOne { public static void main( String[] args) { int count = 0; int count2 = 0; int[] numbers; int[] solutions; solutions = new int[20]; numbers = new int[500]; try { File inputFile = new File("input.txt"); Scanner readFile = new Scanner(inputFile); while (readFile.hasNextLine()) { numbers[count] = readFile.nextInt(); count ++; } readFile.close(); } catch (FileNotFoundException e) { System.out.println("crap"); } for (int i = 0; i < count; i++){ for (int j = 0; j < count; j++){ for (int k = 0; k < count; k++){ if (numbers[i] + numbers[j] + numbers[k] == 2020) { solutions[count2] = numbers[i]; solutions[count2+1] = numbers[j]; solutions[count2+2] = numbers[k]; count2 = count2 + 3; } } } } System.out.println(solutions[0] * solutions[1] * solutions[2]); } }