blob: c23c1bd1ab4dc4544fa935add5c0e6281c42126b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
static INPUT: &'static str = include_str!("one.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}");
}
|