day 5 solved!
This commit is contained in:
parent
883c4bb245
commit
091cad266e
2 changed files with 9 additions and 5 deletions
|
|
@ -2,8 +2,8 @@ use std::fs;
|
|||
use regex::Regex;
|
||||
fn main() {
|
||||
println!("Lets begin, day 5");
|
||||
// let file_path = "src/input.txt";
|
||||
let file_path = "src/example.txt";
|
||||
let file_path = "src/input.txt";
|
||||
// let file_path = "src/example.txt";
|
||||
|
||||
let re = Regex::new(r"(?<low>\d*)-(?<high>\d*)").unwrap();
|
||||
let mut ranges: Vec<(i64, i64)> = Vec::new();
|
||||
|
|
@ -82,9 +82,12 @@ fn main() {
|
|||
|
||||
let mut last_end = -1; //?
|
||||
for mut range in &mut ranges{
|
||||
if range.0 < last_end{
|
||||
if range.0 <= last_end{
|
||||
range.0 = last_end + 1;
|
||||
}
|
||||
if range.1 <= last_end{
|
||||
range.1 = last_end;
|
||||
}
|
||||
last_end = range.1;
|
||||
}
|
||||
|
||||
|
|
@ -106,6 +109,7 @@ fn main() {
|
|||
|
||||
// too low: 330684820916269
|
||||
// too high: 348115621205555
|
||||
// too high: 348115621205536 <-- off by one
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ This year I'll be trying to do it in Rust
|
|||
### 2026 Calendar
|
||||
```
|
||||
1 2 3 4 5 6
|
||||
[**] [**] [**] [**] [* ] [ ]
|
||||
[**] [**] [**] [**] [**] [ ]
|
||||
|
||||
7 8 9 10 11 12
|
||||
[ ] [ ] [ ] [ ] [ ] [ ]
|
||||
|
||||
~~ < 9/24 Stars Collected > ~~
|
||||
~~ < 10/24 Stars Collected > ~~
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue