blob: 824ee5e2317fa46ec06b0738ea8aff2e7f6cfcf2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
mod common;
use common::*;
fn apply_move(grid: &mut Vec::<Vec::<char>>, line: &str) {
let (n, from, to) = read_move(&line);
let first_moved = grid[from-1].len()-n;
let len = grid[from-1].len();
for i in first_moved..len {
let x = grid[from-1][i];
grid[to-1].push(x);
}
grid[from-1].drain(first_moved..len);
}
fn main() {
let mut grid = get_grid_from_stdin();
apply_moves_from_stdin(&mut grid, apply_move);
print_top(&grid);
}
|