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

25
day04/src/main.rs Normal file
View File

@@ -0,0 +1,25 @@
use std::env;
use std::fs;
fn main() {
let input = fs::read_to_string(&env::args().nth(1).unwrap()).unwrap();
let mut sum = 0;
for line in input.lines() {
let (s1, e1, s2, e2) = readline(line);
if s1 <= e2 && s2 <= e1 {
sum += 1;
}
}
println!("Total: {}", sum);
}
fn readline(line: &str) -> (i64, i64, i64, i64) {
let nums: Vec<i64> = line
.split(['-', ','])
.map(|line| line.parse::<i64>().unwrap())
.collect();
(nums[0], nums[1], nums[2], nums[3])
}

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

@@ -0,0 +1,25 @@
use std::env;
use std::fs;
fn main() {
let input = fs::read_to_string(&env::args().nth(1).unwrap()).unwrap();
let mut sum = 0;
for line in input.lines() {
let (s1, e1, s2, e2) = readline(line);
if (s1 <= s2 && e1 >= e2) || (s1 >= s2 && e1 <= e2) {
sum += 1;
}
}
println!("Total: {}", sum);
}
fn readline(line: &str) -> (i64, i64, i64, i64) {
let nums: Vec<i64> = line
.split(['-', ','])
.map(|line| line.parse::<i64>().unwrap())
.collect();
(nums[0], nums[1], nums[2], nums[3])
}