advent/2022/src/day5.rs

30 lines
642 B
Rust
Raw Normal View History

2022-12-06 00:46:00 +00:00
const DATA: &'static str = "
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
";
struct State {
stacks: Vec<Vec<char>>,
}
impl std::str::FromStr for State {
fn from_str(data: &str) -> State {
let lines: Vec<&str> = data.lines().collect();
let mut stacks = Vec::new(Vec::new());
// skip the first row, because it's just the stack numbers
for row in lines.rev().skip(1) {
for (i, ident) in row.split(' ') {
let ident = ident.trim_matches(|c| c == '[' || c == ']');
}
}
}
}