From 77cb70fb394c4edadf30aa88279a5a4898a46a27 Mon Sep 17 00:00:00 2001 From: Fennel Kora Date: Fri, 2 Dec 2022 11:27:38 -0500 Subject: [PATCH] Changed from Rust to Java because I'm a scrub On branch master Changes to be committed: new file: 2022/day01/CalorieCount.java deleted: 2022/day01/calorie_count.rs --- 2022/day01/CalorieCount.java | 27 +++++++++++++++++++++++++++ 2022/day01/calorie_count.rs | 11 ----------- 2 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 2022/day01/CalorieCount.java delete mode 100644 2022/day01/calorie_count.rs diff --git a/2022/day01/CalorieCount.java b/2022/day01/CalorieCount.java new file mode 100644 index 0000000..0b89e56 --- /dev/null +++ b/2022/day01/CalorieCount.java @@ -0,0 +1,27 @@ +import java.nio.file.Paths; +import java.io.IOException; +import java.util.Scanner; + +public class CalorieCount { + public static void main(String[] args) { + try (Scanner inputReader = new Scanner(Paths.get("input.txt"))) { + int maxCals = 0; + while (inputReader.hasNext()) { + int currentCals = 0; + String inLine = new String(); + do { + inLine = inputReader.nextLine(); + if (!inLine.isEmpty()) { + currentCals += Integer.parseInt(inLine); + } + } while (!inLine.isEmpty()); + + if (currentCals > maxCals) {maxCals = currentCals;} + } + System.out.printf("The large calories carried is: %d", maxCals); + } catch (IOException e) { + System.out.println("IOException"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/2022/day01/calorie_count.rs b/2022/day01/calorie_count.rs deleted file mode 100644 index 1b3894f..0000000 --- a/2022/day01/calorie_count.rs +++ /dev/null @@ -1,11 +0,0 @@ -use std::io::prelude::*; -use std::fs; -use std::path::*; - -fn main() { - let mut _max_cals = 0; - let path = Path::new("input.txt"); - let display = path.display(); - - let mut file -}