rustfmt
This commit is contained in:
@ -5,21 +5,24 @@ fn print_stacks(stacks: &Vec<Vec<char>>) {
|
||||
}
|
||||
|
||||
fn stacks_message(stacks: &Vec<Vec<char>>) -> String {
|
||||
stacks.iter().map(|v| {
|
||||
v[v.len() - 1]
|
||||
}).fold(String::new(), |mut s, c| {
|
||||
s.push(c);
|
||||
s
|
||||
})
|
||||
stacks
|
||||
.iter()
|
||||
.map(|v| v[v.len() - 1])
|
||||
.fold(String::new(), |mut s, c| {
|
||||
s.push(c);
|
||||
s
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
const INPUT: &str = include_str!("../input.txt");
|
||||
let chunks = INPUT.split_once("\n\n").unwrap();
|
||||
|
||||
let mut stack_lines: Vec<String> = chunks.0.lines().map(|x| -> String {
|
||||
x.to_string() + " "
|
||||
}).collect();
|
||||
|
||||
let mut stack_lines: Vec<String> = chunks
|
||||
.0
|
||||
.lines()
|
||||
.map(|x| -> String { x.to_string() + " " })
|
||||
.collect();
|
||||
stack_lines.pop();
|
||||
let num_stacks = (stack_lines[0].len() + 1) / 4;
|
||||
|
||||
@ -30,11 +33,11 @@ fn main() {
|
||||
line += " ";
|
||||
|
||||
for i in 0..num_stacks {
|
||||
let c = line.chars().nth(i*4 + 1).unwrap();
|
||||
let c = line.chars().nth(i * 4 + 1).unwrap();
|
||||
if c.is_whitespace() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
stacks[i].push(c);
|
||||
}
|
||||
}
|
||||
@ -66,7 +69,7 @@ fn main() {
|
||||
let to = split[5].parse::<usize>().unwrap() - 1;
|
||||
|
||||
let len = stacks[from].len();
|
||||
let mut x: Vec<char> = stacks[from].drain(len-n..len).collect();
|
||||
let mut x: Vec<char> = stacks[from].drain(len - n..len).collect();
|
||||
stacks[to].append(x.as_mut());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user