Started on aoc 2015, finished day 1

This commit is contained in:
2023-10-11 13:16:21 +02:00
parent c1ac8c30e5
commit 941da35416
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
fn main() {
println!("Hello, this is Patrick!");
let input_txt = include_str!("../input.txt");
let mut floor = 0;
for parenthesis in input_txt.chars() {
match parenthesis {
'(' => floor += 1,
')' => floor -= 1,
_ => (),
}
}
println!("Santa needs to go to floor {}", floor);
let input_txt = include_str!("../input.txt");
let mut floor = 0;
for (idx, parenthesis) in input_txt.chars().enumerate() {
match parenthesis {
'(' => floor += 1,
')' => floor -= 1,
_ => (),
}
if floor == -1 {
println!("Santa first reaches the basement at position {}", idx + 1);
break;
}
}
}