generated from luke-else/AdventOfCodeXXXX
feat: Completed day 7 BACK UP TO DATE!
Some checks failed
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 39s
Continuous integration / Rustfmt (push) Successful in 28s
Continuous integration / Clippy (push) Failing after 39s
Continuous integration / build (push) Successful in 38s
Some checks failed
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 39s
Continuous integration / Rustfmt (push) Successful in 28s
Continuous integration / Clippy (push) Failing after 39s
Continuous integration / build (push) Successful in 38s
This commit is contained in:
142
input/day07
142
input/day07
@@ -0,0 +1,142 @@
|
||||
......................................................................S......................................................................
|
||||
.............................................................................................................................................
|
||||
......................................................................^......................................................................
|
||||
.............................................................................................................................................
|
||||
.....................................................................^.^.....................................................................
|
||||
.............................................................................................................................................
|
||||
....................................................................^.^.^....................................................................
|
||||
.............................................................................................................................................
|
||||
...................................................................^.^...^...................................................................
|
||||
.............................................................................................................................................
|
||||
..................................................................^...^...^..................................................................
|
||||
.............................................................................................................................................
|
||||
.................................................................^...^.^.^.^.................................................................
|
||||
.............................................................................................................................................
|
||||
................................................................^.^...^.^.^.^................................................................
|
||||
.............................................................................................................................................
|
||||
...............................................................^.^.^.^.^.^...^...............................................................
|
||||
.............................................................................................................................................
|
||||
..............................................................^.^...^.^.^.....^..............................................................
|
||||
.............................................................................................................................................
|
||||
.............................................................^.^.^.....^...^.^.^.............................................................
|
||||
.............................................................................................................................................
|
||||
............................................................^.^.^.^...^.^.^.^...^............................................................
|
||||
.............................................................................................................................................
|
||||
...........................................................^.^...^.^.^.^.^.......^...........................................................
|
||||
.............................................................................................................................................
|
||||
..........................................................^.^...^.^.^.^.^.^.^.^...^..........................................................
|
||||
.............................................................................................................................................
|
||||
.........................................................^.^...^...^...^...^.....^.^.........................................................
|
||||
.............................................................................................................................................
|
||||
........................................................^.^.^.^.^.^.^.^.^...^.^...^.^........................................................
|
||||
.............................................................................................................................................
|
||||
.......................................................^.^.^.^...^.^.^.^.^.^.^.^...^.^.......................................................
|
||||
.............................................................................................................................................
|
||||
......................................................^.^.^.^...^.^.....^...^.^.^.^.^.^......................................................
|
||||
.............................................................................................................................................
|
||||
.....................................................^...^.^.^.^.^.^...^.^.^...^.^.^.^.^.....................................................
|
||||
.............................................................................................................................................
|
||||
....................................................^.^.^.^.^.^.^...^.^.^...^.^.^.......^....................................................
|
||||
.............................................................................................................................................
|
||||
...................................................^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...^.^.^...................................................
|
||||
.............................................................................................................................................
|
||||
..................................................^.^...^.^.^...^.^.....^.^.^...^...^.^.^.^..................................................
|
||||
.............................................................................................................................................
|
||||
.................................................^.^.^.^...^...........^.....^.^...^.^.^.^.^.................................................
|
||||
.............................................................................................................................................
|
||||
................................................^.^.^...^.....^.^.^.^.^...^...^.^.^.^.^...^.^................................................
|
||||
.............................................................................................................................................
|
||||
...............................................^...^.^.^.^.........^.^.^.^.^.^.^.^...^.^.^...^...............................................
|
||||
.............................................................................................................................................
|
||||
..............................................^.^.^.^...^.....^...^.^.^.^.^.........^.^.^.^.^.^..............................................
|
||||
.............................................................................................................................................
|
||||
.............................................^.^...^.^...^.^.^.^.........^.^.^.^.^.^.^...^.^.^.^.............................................
|
||||
.............................................................................................................................................
|
||||
............................................^.^.^.....^...^.......^...^.^.....^.^.^.^...^...^...^............................................
|
||||
.............................................................................................................................................
|
||||
...........................................^...^.^...^.^.^.....^.^...^.......^.^...^.^.^.^.......^...........................................
|
||||
.............................................................................................................................................
|
||||
..........................................^.^...^.^...^.^.^.^.^.^.^...^.^.^.^.^.^...^.^.^.^.^.^.^.^..........................................
|
||||
.............................................................................................................................................
|
||||
.........................................^.^.^.^.^.^.^.^.^.^...^...^.^...^.....^.....^.^.^.^.^.^.^.^.........................................
|
||||
.............................................................................................................................................
|
||||
........................................^.^.^.....^.^.^.^.^...^.....^.^.^.^.^...^.^...^.......^.^...^........................................
|
||||
.............................................................................................................................................
|
||||
.......................................^.^.^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^.^.^.^...^.^.^.^.^.^.^.......................................
|
||||
.............................................................................................................................................
|
||||
......................................^...^.^.^.^.^.^.^...^.....^.^.^.^.^.^.^.^...^.^.^.....^.^.^.^...^......................................
|
||||
.............................................................................................................................................
|
||||
.....................................^.^.^...^.^.....^...^.^...^.^.^.^...^.^.^...^.^.......^...^...^.^.^.....................................
|
||||
.............................................................................................................................................
|
||||
....................................^.^.....^.^.^.^.^.^.....^.....^.....^.^...^.^.......^.....^.^.^.^...^....................................
|
||||
.............................................................................................................................................
|
||||
...................................^.^.^.^.^.^.^...^.^.....^.^.^.^...^...^.^.^.^.^.^...^...^...^...^.^...^...................................
|
||||
.............................................................................................................................................
|
||||
..................................^.^.^.^...^.^.^.^.^...^.....^...^.^.^.^.^.^.^.^.^.^.....^.^.^.^...^.^.^.^..................................
|
||||
.............................................................................................................................................
|
||||
.................................^...^...^.^.^.^.^.^.^...^.^...^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^.................................
|
||||
.............................................................................................................................................
|
||||
................................^.^.^.^.^.....^.^...^.^.^.^.^.^.^.^...^...^.^.^.^.....^.^...^.^...^.....^.^.^................................
|
||||
.............................................................................................................................................
|
||||
...............................^...^.....^.^.^.^...^.^.^.^.^.^.^.....^.......^...^...^.^.^...^...^.....^.^...^...............................
|
||||
.............................................................................................................................................
|
||||
..............................^.^.^.^.^.^.^...^.^.^.^.^...^.^.....^...^.^...^.^.^.^.......^.^.^.^.^.^.^...^...^..............................
|
||||
.............................................................................................................................................
|
||||
.............................^.^...^...^.^...^.^.^...^.^.^.^...^...^.^.......^.^.^...^.^.^.^.^...^.^.^.^.^...^.^.............................
|
||||
.............................................................................................................................................
|
||||
............................^.^.^.^.^.^.^.^.^...^...^.^.^.^.......^.^.^.^...^.^.^...^.^...^.^.^.^.^.^...^.^.^.^.^............................
|
||||
.............................................................................................................................................
|
||||
...........................^...^.^.^.^.^.^.^.^.^.^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^...^.^.....^...^...........................
|
||||
.............................................................................................................................................
|
||||
..........................^.^.^...^...^.^.^.^.^.^.....^.....^.^.^.^.^.....^.^.^.^.......^.^.^.^.^...^.^.^.^.^.....^..........................
|
||||
.............................................................................................................................................
|
||||
.........................^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^.^.^.....^.^.^...^...^...^.....^.....^.^.^...^.^...^...^.........................
|
||||
.............................................................................................................................................
|
||||
........................^.....^...^.^...^.....^.^...^...^...^.....^...^.^...^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^.^...^........................
|
||||
.............................................................................................................................................
|
||||
.......................^.^.^.^.......^.^.^.^.^.^...^...^...^.^...^.^.^.^.^.^.^.^...^.^.^.....^.^...^.^.^.^.........^.^.......................
|
||||
.............................................................................................................................................
|
||||
......................^.........^.^.....^.^...^.^.^.^.^.^.^.^...^.^.^...^...^.^...^.^...^.^.^.^.^.^.^...^.^.^.^...^.^.^......................
|
||||
.............................................................................................................................................
|
||||
.....................^.^...^.^...^...^.^.^.^.^...^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.....................
|
||||
.............................................................................................................................................
|
||||
....................^.^...^.^...^...^.^...^.^...^.^.^...^.^.^.^.......^.^.^.^.....^.^.^...^...^.^.^.^.^.^...^.^.^.^.^.^.^....................
|
||||
.............................................................................................................................................
|
||||
...................^.^.^...^.^.....^...^.....^.^.^.^...^.^...^.....^.^.^.^.^.^.^.....^.^.^.......^.^.^.^.^.^.....^.^.^.^.^...................
|
||||
.............................................................................................................................................
|
||||
..................^...^...^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^...^...^...^..................
|
||||
.............................................................................................................................................
|
||||
.................^.^...^.^.^.^...^.^.^.^.^...^.^.^.^.^...^...^.^...^...^.^...^...^.^.....^.^.^.^.^.^.^.^.^.^...^.^...^.^...^.................
|
||||
.............................................................................................................................................
|
||||
................^.^.^.^...^.^...^.^.^...^.^.^...^.^.^.^...^.....^.....^.^...^.^.^.^...^.^...^.^.^.....^...^.^.^.^...^...^.^.^................
|
||||
.............................................................................................................................................
|
||||
...............^.^.....^.^.^.......^...^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^.....^.^.....^.^...^.^.^.^.^.^.^.^...^.^.^.^.^...............
|
||||
.............................................................................................................................................
|
||||
..............^.^.^.....^.^...^.....^.^.....^...^.^.^.^.^...^.^.^.^.^.^.^.^.^.^...^.^...^.^.......^.^.^.^.^.^.^.^.^.....^.^.^.^..............
|
||||
.............................................................................................................................................
|
||||
.............^.^...^.^.^.^.....^...^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^...^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.............
|
||||
.............................................................................................................................................
|
||||
............^.....^.^...^.^.^.^.^.^.^.^...^.^.^.^.....^.^.^.^.^...^.^.^.^...^.^.^...........^...^.^...^.^.^.^.^.^.^...^.^.^.....^............
|
||||
.............................................................................................................................................
|
||||
...........^...^.^...^.^.^.^.^.^.^.^.^.^.^.^.....^.....^.^.^.^.^...^.^...^.^.^...^...^...^.^.^.^.......^.....^.^.^.^...^...^.^.^.^...........
|
||||
.............................................................................................................................................
|
||||
..........^.^.^.^.^.......^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.^...^.^...^.^...^.^.....^.^.^.^...^.^.^.^.^.^.^.^.^.....^...^..........
|
||||
.............................................................................................................................................
|
||||
.........^.^.^.^...^.^.^...^.^.^.^...^.^...........^.^...^.^...^.^.^.....^.^.^.^.^...^.^...^.^.....^...^.^.^.^.^.^.^.^.^.^.^.^...^.^.........
|
||||
.............................................................................................................................................
|
||||
........^.^.^...^.^.^.^...^.^.^...^.^.^...^...^.^...^...^...^.^.....^.^.....^.....^...^.^.^.^.^.^.....^.^.^.^.^.^.....^.^.^...^.^.^.^........
|
||||
.............................................................................................................................................
|
||||
.......^.^...^...^...^.^.....^.^.^.^...^.^.^.^.....^...^...^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^...^...^.^.^.^.^.^.^.....^.....^.......
|
||||
.............................................................................................................................................
|
||||
......^.^.^.....^.......^.^.^.^...^.^...^.^...^.........^.^.^.^.....^.^.^.....^.^...^...^...^.^...^...^...........^...^.^.....^.^.^...^......
|
||||
.............................................................................................................................................
|
||||
.....^.^.^.^.....^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^...........^.^...^.^...^.^...^...^.^.^...^.^...^.......^...^.^.^.^.^.^...^.^.^...^.....
|
||||
.............................................................................................................................................
|
||||
....^.^...^...^.^.^.....^.^.^.^.^.^...^.......^.....^...^.^...^.^...^.....^.^.^.^.^.^.......^.^...^...^.^...^.^.^.^.^.^.^.^...^.^.^.^.^.^....
|
||||
.............................................................................................................................................
|
||||
...^.^...^.^...^.^...^.^.^.^.^.^.........^.^.^...^...^...^.^.^...^.^.^.^.^.....^.^...^.........^...^.^.^...^.^...^.....^.......^.^.....^.^...
|
||||
.............................................................................................................................................
|
||||
..^.^.^.^.^...^.^...^.^.^...^.^.^...^...^...^.^.^.^.^.^.^...^.^.^...^...^.^...^.^.^.^...^.......^.^.^.^...^.^.......^.^...^.^...^.^.^.^...^..
|
||||
.............................................................................................................................................
|
||||
.^.^.^.^...^...^...^...^.^.....^...^.^.^...^.^.^.^.^.^...^.^.^.^.........^.^.^.^...^.^...^...^.^.....^...^.^.^.^...^.^...^...^.^.^.^.^...^.^.
|
||||
.............................................................................................................................................
|
||||
@@ -0,0 +1,16 @@
|
||||
.......S.......
|
||||
...............
|
||||
.......^.......
|
||||
...............
|
||||
......^.^......
|
||||
...............
|
||||
.....^.^.^.....
|
||||
...............
|
||||
....^.^...^....
|
||||
...............
|
||||
...^.^...^.^...
|
||||
...............
|
||||
..^...^.....^..
|
||||
...............
|
||||
.^.^.^.^.^...^.
|
||||
...............
|
||||
@@ -0,0 +1,16 @@
|
||||
.......S.......
|
||||
...............
|
||||
.......^.......
|
||||
...............
|
||||
......^.^......
|
||||
...............
|
||||
.....^.^.^.....
|
||||
...............
|
||||
....^.^...^....
|
||||
...............
|
||||
...^.^...^.^...
|
||||
...............
|
||||
..^...^.....^..
|
||||
...............
|
||||
.^.^.^.^.^...^.
|
||||
...............
|
||||
@@ -61,7 +61,6 @@ impl Solution for Day06 {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
println!("Problem: {:?} {}, Result: {}", numbers, op, result);
|
||||
grand_total += result;
|
||||
}
|
||||
Ok(Box::new(grand_total))
|
||||
|
||||
@@ -5,16 +5,18 @@ pub struct Day07 {}
|
||||
impl Solution for Day07 {
|
||||
fn part1(
|
||||
&self,
|
||||
_input: &mut Vec<String>,
|
||||
input: &mut Vec<String>,
|
||||
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
||||
Ok(Box::new("Ready"))
|
||||
let (p1, _p2) = self.solve_paths(input);
|
||||
Ok(Box::new(p1))
|
||||
}
|
||||
|
||||
fn part2(
|
||||
&self,
|
||||
_input: &mut Vec<String>,
|
||||
input: &mut Vec<String>,
|
||||
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
||||
Ok(Box::new("Ready"))
|
||||
let (_p1, p2) = self.solve_paths(input);
|
||||
Ok(Box::new(p2))
|
||||
}
|
||||
|
||||
fn get_day(&self) -> u8 {
|
||||
@@ -22,7 +24,43 @@ impl Solution for Day07 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Day07 {}
|
||||
impl Day07 {
|
||||
fn solve_paths(&self, input: &Vec<String>) -> (usize, usize) {
|
||||
let lines: Vec<_> = input.iter().map(String::as_bytes).collect();
|
||||
let width = lines[0].len();
|
||||
let start = lines[0].iter().position(|&b| b == b'S').unwrap();
|
||||
|
||||
let mut splits = 0;
|
||||
let mut current = vec![0; width];
|
||||
let mut next = vec![0; width];
|
||||
|
||||
current[start] = 1;
|
||||
|
||||
for row in lines {
|
||||
for (i, &count) in current.iter().enumerate() {
|
||||
if count > 0 {
|
||||
if row[i] == b'^' {
|
||||
splits += 1;
|
||||
|
||||
if i > 0 {
|
||||
next[i - 1] += count;
|
||||
}
|
||||
if i < width - 1 {
|
||||
next[i + 1] += count;
|
||||
}
|
||||
} else {
|
||||
next[i] += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(current, next) = (next, current);
|
||||
next.fill(0);
|
||||
}
|
||||
|
||||
(splits, current.iter().sum())
|
||||
}
|
||||
}
|
||||
|
||||
/// Test from puzzle input
|
||||
#[cfg(test)]
|
||||
@@ -44,7 +82,7 @@ mod test {
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
assert_eq!(answer, "Ready");
|
||||
assert_eq!(answer, "21");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -61,6 +99,6 @@ mod test {
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
assert_eq!(answer, "Ready");
|
||||
assert_eq!(answer, "40");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user