A bit of cleanup.

This commit is contained in:
Anna Rose 2024-02-18 22:22:37 +00:00
parent e0cd4c3f98
commit 8bbc7bf653

View File

@ -38,10 +38,10 @@ fn initialize_stacks(stacks: &mut [Vec<char>], text: &str) {
} }
fn move_stacks(stacks: &mut [Vec<char>], text: &str, step: u8) { fn move_stacks(stacks: &mut [Vec<char>], text: &str, step: u8) {
let fields: Vec<_> = text.split(' ').collect(); let fields = text.split(' ').collect::<Vec<_>>();
let count = fields[1].parse::<usize>().unwrap(); let count = fields[1].parse::<usize>().unwrap();
let start = fields[3].parse::<usize>().unwrap(); let start = fields[3].parse::<usize>().unwrap();
let end = fields[5].parse::<usize>().unwrap(); let end = fields[5].parse::<usize>().unwrap();
let mut crane = vec![]; let mut crane = vec![];
for _ in 0..count { for _ in 0..count {
@ -54,9 +54,7 @@ fn move_stacks(stacks: &mut [Vec<char>], text: &str, step: u8) {
} }
// if we're doing step 1, we're done // if we're doing step 1, we're done
if crane.is_empty() { if crane.is_empty() { return; }
return;
}
// step 2 logic // step 2 logic
while let Some(item) = crane.pop() { while let Some(item) = crane.pop() {