mirror of
https://github.com/Zormm/Advent-Of-Code-2022.git
synced 2026-02-26 07:26:51 +01:00
Renamed Folders and added Idea for Day 19
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Advent of Code 2022 Day 1</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1671521328686</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
+2244
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
ArrayList<Integer> caloriesByElf = new ArrayList<Integer>();
|
||||
int calories = 0;
|
||||
|
||||
try {
|
||||
//Part 1
|
||||
System.out.print("Part 1: ");
|
||||
RandomAccessFile file = new RandomAccessFile("input.txt", "r");
|
||||
String str;
|
||||
|
||||
while ((str = file.readLine()) != null) {
|
||||
if (str.equals("")) {
|
||||
caloriesByElf.add(calories);
|
||||
calories = 0;
|
||||
}
|
||||
else
|
||||
calories += Integer.valueOf(str);
|
||||
}
|
||||
caloriesByElf.add(calories);
|
||||
file.close();
|
||||
|
||||
caloriesByElf.sort(null);
|
||||
|
||||
System.out.println(caloriesByElf.get(caloriesByElf.size()-1));
|
||||
//Part 2
|
||||
System.out.print("Part 2: ");
|
||||
int top3CalorieCountsCombined = 0;
|
||||
|
||||
for (int i = caloriesByElf.size()-1; i > caloriesByElf.size()-4;i--) {
|
||||
top3CalorieCountsCombined += caloriesByElf.get(i);
|
||||
}
|
||||
|
||||
System.out.println(top3CalorieCountsCombined);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user