Optimized day 5 part 2
This commit is contained in:
parent
384625e7a6
commit
12439c6ed7
|
@ -122,9 +122,7 @@ fn solution(mut input: Stack) -> String {
|
||||||
for ins in input.instructions {
|
for ins in input.instructions {
|
||||||
let l = input.stacks[ins.from - 1].len();
|
let l = input.stacks[ins.from - 1].len();
|
||||||
|
|
||||||
let crates: Vec<u8> = input.stacks[ins.from - 1]
|
let crates = input.stacks[ins.from - 1].split_off(l.saturating_sub(ins.count));
|
||||||
.drain(l.saturating_sub(ins.count)..l)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
input.stacks[ins.to - 1].extend(crates);
|
input.stacks[ins.to - 1].extend(crates);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user