diff --git a/2022/src/day5.rs b/2022/src/day5.rs new file mode 100644 index 0000000..313e8ff --- /dev/null +++ b/2022/src/day5.rs @@ -0,0 +1,29 @@ +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>, +} + +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 == ']'); + } + } + } +}