summaryrefslogtreecommitdiffstats
path: root/2015/rs/code/one/src/main.rs
blob: 131cf877346e2ce46428e1a63b871966f4227300 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
static INPUT: &str = include_str!("input.txt");

fn main() {
  let valueified = INPUT.chars().map(|c| match c { '(' => 1, ')' => -1, _ => 0});
  let floor_number: i32 = valueified.clone().sum();
  println!("Floor number: {floor_number}");

  let mut floor = 0;
  let basement_index = valueified.take_while(|i| {floor += i; floor >= 0}).count() + 1;
  println!("First character in basement: {basement_index}");
}