Forgot to commit some files + small cleanup
This commit is contained in:
30
src/day1.rs
30
src/day1.rs
@@ -57,34 +57,4 @@ fn find_triplet_summing_to(nums: &Vec<u32>, target: u32) -> (u32, u32, u32){
|
||||
}
|
||||
}
|
||||
panic!("Couldn't find match!");
|
||||
|
||||
//
|
||||
// let mut i:usize = 0;
|
||||
// let mut j:usize = nums.len() - 1;
|
||||
// loop {
|
||||
// if j < i {
|
||||
//
|
||||
// // Reset with i one higher:
|
||||
// i += 1;
|
||||
// j = nums.len() - 1;
|
||||
// }
|
||||
//
|
||||
// let n1 = nums[i];
|
||||
// let n2 = nums[j];
|
||||
// let sum = n1 + n2;
|
||||
// if sum + n1 > target {
|
||||
// j -= 1;
|
||||
// } else {
|
||||
// // See if we can find a third number between i and j that makes the sum equal to the target
|
||||
// let n3_target = target - sum;
|
||||
// let res = nums.binary_search(&n3_target);
|
||||
// if res.is_ok() {
|
||||
// // Found it!
|
||||
// return (n1, n2, n3_target)
|
||||
// } else {
|
||||
// j -= 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
24
src/main.rs
Normal file
24
src/main.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use std::time::Instant;
|
||||
|
||||
mod util;
|
||||
mod day1;
|
||||
|
||||
fn main() {
|
||||
|
||||
let now = Instant::now();
|
||||
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let day_arg_idx = args.iter().position(|a| a == "-d");
|
||||
if day_arg_idx.is_some() {
|
||||
match args[day_arg_idx.unwrap() + 1].parse::<u8>().unwrap() {
|
||||
1 => day1::solve(),
|
||||
_ => println!("This day is not yet implemented")
|
||||
}
|
||||
} else {
|
||||
// Solve all days:
|
||||
day1::solve();
|
||||
}
|
||||
|
||||
println!("Execution took {} μs", now.elapsed().as_micros());
|
||||
}
|
||||
Reference in New Issue
Block a user