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