Compare commits
5 Commits
master
...
d8f191fd9b
Author | SHA1 | Date | |
---|---|---|---|
d8f191fd9b | |||
77cb399748 | |||
beeb89a2f6 | |||
64851dd68b | |||
2fd479d02d |
46
Cargo.toml
46
Cargo.toml
@ -10,30 +10,30 @@ chrono = "0.4.23"
|
|||||||
regex = "1.7.0"
|
regex = "1.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["a", "b", "today"]
|
default = ["part1", "part2", "today"]
|
||||||
a = []
|
part1 = []
|
||||||
b = []
|
part2 = []
|
||||||
today = []
|
today = []
|
||||||
01 = []
|
day01 = []
|
||||||
02 = []
|
day02 = []
|
||||||
03 = []
|
day03 = []
|
||||||
04 = []
|
day04 = []
|
||||||
05 = []
|
day05 = []
|
||||||
06 = []
|
day06 = []
|
||||||
07 = []
|
day07 = []
|
||||||
08 = []
|
day08 = []
|
||||||
09 = []
|
day09 = []
|
||||||
10 = []
|
day10 = []
|
||||||
11 = []
|
day11 = []
|
||||||
12 = []
|
day12 = []
|
||||||
13 = []
|
day13 = []
|
||||||
14 = []
|
day14 = []
|
||||||
15 = []
|
day15 = []
|
||||||
16 = []
|
day16 = []
|
||||||
17 = []
|
day17 = []
|
||||||
18 = []
|
day18 = []
|
||||||
19 = []
|
day19 = []
|
||||||
20 = []
|
day20 = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2235
input/01.txt
2235
input/01.txt
File diff suppressed because it is too large
Load Diff
@ -2,4 +2,29 @@ use crate::read;
|
|||||||
|
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
let input = read("01");
|
let input = read("01");
|
||||||
|
let elves = vec![0];
|
||||||
|
|
||||||
|
let mut elves = input.lines().fold(elves, |mut acc, x|{
|
||||||
|
if x.is_empty() {
|
||||||
|
acc.push(0);
|
||||||
|
} else {
|
||||||
|
let num: i32 = x.parse().unwrap();
|
||||||
|
*acc.last_mut().unwrap() += num;
|
||||||
|
}
|
||||||
|
acc
|
||||||
|
});
|
||||||
|
elves.sort();
|
||||||
|
elves.reverse();
|
||||||
|
|
||||||
|
#[cfg(feature="part1")]
|
||||||
|
{
|
||||||
|
let a = elves.first().unwrap();
|
||||||
|
eprintln!("Part 01: {}", *a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="part2")]
|
||||||
|
{
|
||||||
|
let b = elves[..3].iter().sum::<i32>();
|
||||||
|
eprintln!("Part 02: {}", b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
20
src/day02/mod.rs
Normal file
20
src/day02/mod.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
use crate::read;
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
let input = read("02");
|
||||||
|
let lines = input.lines();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(feature="part1")]
|
||||||
|
{
|
||||||
|
let a = "TODO";
|
||||||
|
eprintln!("Day 2, Part 01: {}", a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="part2")]
|
||||||
|
{
|
||||||
|
let b = "TODO";
|
||||||
|
eprintln!("Day 2, Part 02: {}", b);
|
||||||
|
}
|
||||||
|
}
|
10
src/main.rs
10
src/main.rs
@ -1,17 +1,17 @@
|
|||||||
|
use chrono::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use chrono::prelude::*;
|
|
||||||
mod day01;
|
mod day01;
|
||||||
|
mod day02;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let today = Local::now().day();
|
let today = Local::now().day();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
if cfg!(feature ="day01") || (cfg!(feature ="today") && today == 1) {
|
if cfg!(feature = "day01") || (cfg!(feature = "today") && today == 1) {
|
||||||
day01::run();
|
day01::run();
|
||||||
}
|
}
|
||||||
if cfg!(feature ="day02") || (cfg!(feature ="today") && today == 2) {
|
if cfg!(feature = "day02") || (cfg!(feature = "today") && today == 2) {
|
||||||
todo!()
|
day02::run();
|
||||||
//day02::run();
|
|
||||||
}
|
}
|
||||||
println!("Finished, time taken: {:?}", now.elapsed())
|
println!("Finished, time taken: {:?}", now.elapsed())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user