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
This commit is contained in:
parent
a45b30e010
commit
77cb70fb39
2 changed files with 27 additions and 11 deletions
27
2022/day01/CalorieCount.java
Normal file
27
2022/day01/CalorieCount.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue