diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-26 09:47:23 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-26 23:37:23 +0200 |
| commit | fa26f694d8cf98272763952a698301ee9935c19e (patch) | |
| tree | 5af7a788fb8e9fa12b2b2fbea64250ed496a23c0 /2022/08/common.rs | |
| parent | f0159b7d36e2c81182f2d047a34bf883394894db (diff) | |
| download | aoc-fa26f694d8cf98272763952a698301ee9935c19e.tar.gz aoc-fa26f694d8cf98272763952a698301ee9935c19e.zip | |
Added 2022, first few problems
Diffstat (limited to '2022/08/common.rs')
| -rw-r--r-- | 2022/08/common.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/2022/08/common.rs b/2022/08/common.rs new file mode 100644 index 0000000..45fbf10 --- /dev/null +++ b/2022/08/common.rs | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | pub type Grid = Vec<Vec<(i8, bool)>>; | ||
| 2 | |||
| 3 | pub fn read_grid_from_stdin() -> Grid { | ||
| 4 | let mut grid = Vec::<Vec<(i8, bool)>>::new(); | ||
| 5 | let mut line = String::new(); | ||
| 6 | while std::io::stdin().read_line(&mut line).unwrap() > 0 { | ||
| 7 | let row = line[..line.len()-1].as_bytes().iter() | ||
| 8 | .map(|b| ((*b as i8) - ('0' as i8), false)).collect(); | ||
| 9 | grid.push(row); | ||
| 10 | line.clear(); | ||
| 11 | } | ||
| 12 | grid | ||
| 13 | } | ||
