Stage 1
This commit is contained in:
parent
fc496204e7
commit
e6471a3c3f
1 changed files with 23 additions and 3 deletions
|
|
@ -3,12 +3,32 @@ use crate::days::Solution;
|
|||
pub struct Day01;
|
||||
|
||||
impl Solution for Day01 {
|
||||
type Input = ();
|
||||
type Input = Vec<i16>;
|
||||
|
||||
fn parse(&self, data: &str) -> Self::Input {}
|
||||
fn parse(&self, data: &str) -> Self::Input {
|
||||
data.split("\n")
|
||||
.map(|l| {
|
||||
let mut chars = l.chars();
|
||||
let first = chars.next();
|
||||
let num = chars.collect::<String>().parse::<i16>();
|
||||
|
||||
match (first, num) {
|
||||
(Some('L'), Ok(n)) => -1 * n,
|
||||
(Some('R'), Ok(n)) => n,
|
||||
_ => 0,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn part1(&self, input: &Self::Input) -> usize {
|
||||
0
|
||||
input
|
||||
.iter()
|
||||
.fold((50, 0), |(sum, res), x| match (sum + x) % 100 {
|
||||
0 => (0, res + 1),
|
||||
newsum => (newsum, res),
|
||||
})
|
||||
.1
|
||||
}
|
||||
|
||||
fn part2(&self, input: &Self::Input) -> usize {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue