aoc2023/src/main.rs

51 lines
985 B
Rust

use anyhow::Result;
use std::io::stdin;
type Row = Vec<char>;
type Grid = Vec<Row>;
fn roll_left(row: &mut Row) {
}
fn roll_column_up(grid: &mut Grid, col: usize) {
}
fn roll_up(grid: &mut Grid) {
}
fn main() -> Result<()> {
let mut grid: Grid = vec![];
for line in stdin().lines().map_while(Result::ok) {
grid.push(line.chars().collect());
}
let height = grid.len();
let width = grid[0].len();
let mut total_load = 0;
for x in 0..width {
let mut column_load = 0;
let mut load = height;
for (y, row) in grid.iter().enumerate() {
match row[x] {
'O' => {
column_load += load;
load -= 1;
}
'#' => {
load = height - y - 1;
}
_ => {}
}
}
total_load += column_load;
}
println!("{total_load}");
Ok(())
}
#[cfg(test)]
mod tests {}