pad numbers on directory names

This commit is contained in:
2024-03-12 22:42:38 -07:00
parent efd1fb5ca9
commit f2eb9929d7
55 changed files with 0 additions and 0 deletions

7
day01/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "day1"
version = "0.1.0"

8
day01/Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "day1"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

2256
day01/input.txt Normal file

File diff suppressed because it is too large Load Diff

32
day01/src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
fn main() {
let args: Vec<String> = env::args().collect();
let input = &args[1];
let reader = BufReader::new(File::open(input).expect("where file?"));
let (mut sum, mut max1, mut max2, mut max3) = (0, 0, 0, 0);
for line in reader.lines() {
if !line.as_ref().unwrap().trim().is_empty() {
sum += line.unwrap().parse::<i64>().unwrap();
} else {
println!(" {}? {} {} {}", sum, max1, max2, max3);
if sum > max1 {
max3 = max2;
max2 = max1;
max1 = sum;
} else if sum > max2 {
max3 = max2;
max2 = sum;
} else if sum > max3 {
max3 = sum;
}
sum = 0;
}
}
println!("Max3: {}", max1 + max2 + max3);
}

25
day01/src/main1.rs Normal file
View File

@@ -0,0 +1,25 @@
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
fn main() {
let args: Vec<String> = env::args().collect();
let input = &args[1];
let reader = BufReader::new(File::open(input).expect("where file?"));
let mut sum: i64 = 0;
let mut max: i64 = 0;
for line in reader.lines() {
if !line.as_ref().unwrap().trim().is_empty() {
sum += line.unwrap().parse::<i64>().unwrap();
} else {
if sum > max {
max = sum;
}
sum = 0;
}
}
println!("Max: {}", max);
}

15
day01/test.txt Normal file
View File

@@ -0,0 +1,15 @@
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000