Big update: Adding all advent of codes to same repo

This commit is contained in:
2024-12-06 00:14:09 +00:00
parent 5116bd4696
commit 233dda4fe9
106 changed files with 7790 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,41 @@
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
class day1 {
public static void main(String[] args) {
try {
File myFile = new File("input.txt");
Scanner in = new Scanner(myFile);
int[] input = new int[200];
for (int i = 0; i < 200; i++) {
input[i] = Integer.parseInt(in.next());
}
for (int i = 0; i < 198; i++) {
for (int j = i + 1; j < 199; j++) {
//Following is for part1
//if (input[i] + input[j] == 2020) {
//System.out.println(input[i] * input[j]);
//}
for (int k = j + 1; k < 200; k++) {
if (input[i] + input[j] + input[k] == 2020) {
System.out.println(input[i] * input[j] * input[k]);
}
}
}
}
in.close();
} catch (FileNotFoundException e) {
System.out.println(e);
}
}
}