Solved day 5

This commit is contained in:
gabe 2022-12-05 01:48:20 -06:00
parent c92c8843e9
commit 5030dfa2a4
11 changed files with 786 additions and 14 deletions

View file

@ -1,7 +1,15 @@
use crate::utilities::*;
pub fn part2() -> usize {
unimplemented!()
pub fn part2(input: &(WorkArea, Vec<Move>)) -> Vec<char> {
let (mut work_area, moves) = input.to_owned();
for r#move in moves {
work_area.apply_move_cratemover9001(&r#move)
}
work_area
.get_stacks()
.iter()
.map(|stack| stack.last().unwrap().to_owned())
.collect()
}
#[cfg(test)]
@ -10,6 +18,31 @@ mod tests {
#[test]
fn test_part2() {
assert_eq!(part2(), 0);
let input = (
WorkArea::new(vec![vec!['Z', 'N'], vec!['M', 'C', 'D'], vec!['P']]),
vec![
Move {
to: 1,
from: 2,
number: 1,
},
Move {
to: 3,
from: 1,
number: 3,
},
Move {
to: 1,
from: 2,
number: 2,
},
Move {
to: 2,
from: 1,
number: 1,
},
],
);
assert_eq!(part2(&input), vec!['M', 'C', 'D']);
}
}