aboutsummaryrefslogtreecommitdiff
path: root/2022/05/a.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/05/a.rs')
-rw-r--r--2022/05/a.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/2022/05/a.rs b/2022/05/a.rs
new file mode 100644
index 0000000..ae0e937
--- /dev/null
+++ b/2022/05/a.rs
@@ -0,0 +1,17 @@
1mod common;
2use common::*;
3
4fn apply_move(grid: &mut Vec::<Vec::<char>>, line: &str) {
5 let (n, from, to) = read_move(&line);
6
7 for _ in 0..n {
8 let x = grid[from-1].pop().unwrap();
9 grid[to-1].push(x);
10 }
11}
12
13fn main() {
14 let mut grid = get_grid_from_stdin();
15 apply_moves_from_stdin(&mut grid, apply_move);
16 print_top(&grid);
17}

Generated with cgit - Back to sebastiano.tronto.net