Commits vergleichen
Keine gemeinsamen Commits. „0aa363cb742a4a7a4ef7043c45e8eee1273e8066“ und „5129d46b3553d439dbb4edb7aa994d43040b324f“ haben vollständig unterschiedliche Historien.
0aa363cb74
...
5129d46b35
25 geänderte Dateien mit 81 neuen und 176 gelöschten Zeilen
|
@ -1,11 +0,0 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = truew
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
100
Cargo.toml
100
Cargo.toml
|
@ -9,301 +9,301 @@ description = "My solutions for Advent of code 2024"
|
|||
name = "2023-01"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/01.rs"
|
||||
path = "src/bin/2023/01.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-02"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/02.rs"
|
||||
path = "src/bin/2023/02.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-03"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/03.rs"
|
||||
path = "src/bin/2023/03.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-04"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/04.rs"
|
||||
path = "src/bin/2023/04.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-05"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/05.rs"
|
||||
path = "src/bin/2023/05.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-06"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/06.rs"
|
||||
path = "src/bin/2023/06.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-07"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/07.rs"
|
||||
path = "src/bin/2023/07.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-08"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/08.rs"
|
||||
path = "src/bin/2023/08.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-09"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/09.rs"
|
||||
path = "src/bin/2023/09.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-10"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/10.rs"
|
||||
path = "src/bin/2023/10.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-11"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/11.rs"
|
||||
path = "src/bin/2023/11.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-12"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/12.rs"
|
||||
path = "src/bin/2023/12.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-13"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/13.rs"
|
||||
path = "src/bin/2023/13.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-14"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/14.rs"
|
||||
path = "src/bin/2023/14.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-15"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/15.rs"
|
||||
path = "src/bin/2023/15.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-16"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/16.rs"
|
||||
path = "src/bin/2023/16.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-17"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/17.rs"
|
||||
path = "src/bin/2023/17.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-18"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/18.rs"
|
||||
path = "src/bin/2023/18.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-19"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/19.rs"
|
||||
path = "src/bin/2023/19.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-20"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/20.rs"
|
||||
path = "src/bin/2023/20.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-21"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/21.rs"
|
||||
path = "src/bin/2023/21.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-22"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/22.rs"
|
||||
path = "src/bin/2023/22.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-23"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/23.rs"
|
||||
path = "src/bin/2023/23.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-24"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/24.rs"
|
||||
path = "src/bin/2023/24.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2023-25"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2023/25.rs"
|
||||
path = "src/bin/2023/25.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-01"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/01.rs"
|
||||
path = "src/bin/2024/01.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-02"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/02.rs"
|
||||
path = "src/bin/2024/02.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-03"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/03.rs"
|
||||
path = "src/bin/2024/03.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-04"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/04.rs"
|
||||
path = "src/bin/2024/04.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-05"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/05.rs"
|
||||
path = "src/bin/2024/05.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-06"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/06.rs"
|
||||
path = "src/bin/2024/06.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-07"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/07.rs"
|
||||
path = "src/bin/2024/07.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-08"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/08.rs"
|
||||
path = "src/bin/2024/08.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-09"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/09.rs"
|
||||
path = "src/bin/2024/09.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-10"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/10.rs"
|
||||
path = "src/bin/2024/10.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-11"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/11.rs"
|
||||
path = "src/bin/2024/11.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-12"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/12.rs"
|
||||
path = "src/bin/2024/12.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-13"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/13.rs"
|
||||
path = "src/bin/2024/13.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-14"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/14.rs"
|
||||
path = "src/bin/2024/14.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-15"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/15.rs"
|
||||
path = "src/bin/2024/15.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-16"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/16.rs"
|
||||
path = "src/bin/2024/16.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-17"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/17.rs"
|
||||
path = "src/bin/2024/17.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-18"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/18.rs"
|
||||
path = "src/bin/2024/18.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-19"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/19.rs"
|
||||
path = "src/bin/2024/19.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-20"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/20.rs"
|
||||
path = "src/bin/2024/20.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-21"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/21.rs"
|
||||
path = "src/bin/2024/21.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-22"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/22.rs"
|
||||
path = "src/bin/2024/22.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-23"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/23.rs"
|
||||
path = "src/bin/2024/23.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-24"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/24.rs"
|
||||
path = "src/bin/2024/24.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "2024-25"
|
||||
test = false
|
||||
bench = false
|
||||
path = "days/2024/25.rs"
|
||||
path = "src/bin/2024/25.rs"
|
||||
|
||||
[lib]
|
||||
name = "advent_of_code"
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
467..114..
|
||||
...*......
|
||||
..35..633.
|
||||
......#...
|
||||
617*......
|
||||
.....+.58.
|
||||
..592.....
|
||||
......755.
|
||||
...$.*....
|
||||
.664.598..
|
|
@ -1,10 +0,0 @@
|
|||
MMMSXXMASM
|
||||
MSAMXMSMSA
|
||||
AMXSXMAAMM
|
||||
MSAMASMSMX
|
||||
XMASAMXAMM
|
||||
XXAMMXXAMA
|
||||
SMSMSASXSS
|
||||
SAXAMASAAA
|
||||
MAMMMXMMMM
|
||||
MXMXAXMASX
|
|
@ -7,4 +7,4 @@ XXAMMXXAMA
|
|||
SMSMSASXSS
|
||||
SAXAMASAAA
|
||||
MAMMMXMMMM
|
||||
MXMXAXMASX
|
||||
MXMXAXMASX
|
|
@ -9,4 +9,4 @@ p=3,0 v=-1,-2
|
|||
p=9,3 v=2,3
|
||||
p=7,3 v=-1,2
|
||||
p=2,4 v=2,-3
|
||||
p=9,5 v=-3,-3
|
||||
p=9,5 v=-3,-3
|
|
@ -7,4 +7,4 @@
|
|||
#......#
|
||||
########
|
||||
|
||||
<^^>>>vv<v>>v<<
|
||||
<^^>>>vv<v>>v<<
|
|
@ -24,4 +24,4 @@
|
|||
#..####...................#
|
||||
#.#######################.#
|
||||
#S........................#
|
||||
###########################
|
||||
###########################
|
|
@ -1,4 +1,4 @@
|
|||
# Examples
|
||||
|
||||
# 16c
|
||||
Thanks to Thanks to https://www.reddit.com/r/adventofcode/comments/1hfhgl1/2024_day_16_part_1_alternate_test_case/
|
||||
Thanks to Thanks to https://www.reddit.com/r/adventofcode/comments/1hfhgl1/2024_day_16_part_1_alternate_test_case/
|
|
@ -42,11 +42,7 @@ impl Round {
|
|||
ok
|
||||
}
|
||||
fn power(&self) -> u64 {
|
||||
let mut sack = Sack {
|
||||
reds: 0,
|
||||
greens: 0,
|
||||
blues: 0,
|
||||
};
|
||||
let mut sack = Sack { reds: 0, greens: 0, blues: 0 };
|
||||
for take in self.takes.clone() {
|
||||
if take.red > sack.reds {
|
||||
sack.reds = take.red
|
||||
|
@ -70,11 +66,7 @@ impl From<&str> for Round {
|
|||
takes: Vec::<Take>::new(),
|
||||
};
|
||||
for taking in value.get(doublecolon + 1..).unwrap().split(";") {
|
||||
let mut take = Take {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
};
|
||||
let mut take = Take { red: 0, green: 0, blue: 0 };
|
||||
for color in taking.split(',').map(str::trim) {
|
||||
let mut i = color.splitn(2, char::is_whitespace);
|
||||
let amount = parsenumber(i.next().unwrap());
|
||||
|
@ -96,11 +88,7 @@ fn main() {
|
|||
for game in DATA.split('\n') {
|
||||
gamerounds.push(game.into());
|
||||
}
|
||||
let sack = Sack {
|
||||
reds: 12,
|
||||
greens: 13,
|
||||
blues: 14,
|
||||
};
|
||||
let sack = Sack { reds: 12, greens: 13, blues: 14 };
|
||||
let mut sum = 0;
|
||||
for round in gamerounds.clone() {
|
||||
if round.possible(sack) {
|
|
@ -49,10 +49,7 @@ fn get_x(list: Vec<TextPos>) -> usize {
|
|||
fn follow_text(data: &Table, start_point: Kartesian<usize>, direction: KartesianDirection, current_pos: Kartesian<usize>, chars: Vec<char>, list: &mut Vec<TextPos>) {
|
||||
let mut iter = chars.iter().cloned();
|
||||
match iter.next() {
|
||||
None => list.push(TextPos {
|
||||
start: start_point,
|
||||
end: current_pos,
|
||||
}),
|
||||
None => list.push(TextPos { start: start_point, end: current_pos }),
|
||||
Some(c) => match current_pos.move_dir_max(direction.vector_abs(), direction, Kartesian::maximum(data)) {
|
||||
None => return,
|
||||
Some(new) => {
|
|
@ -18,23 +18,13 @@ struct DirectionalKartesian<T: Integer> {
|
|||
}
|
||||
impl<T: Integer> From<(Kartesian<T>, KartesianDirection)> for DirectionalKartesian<T> {
|
||||
fn from(value: (Kartesian<T>, KartesianDirection)) -> Self {
|
||||
DirectionalKartesian {
|
||||
x: value.0.x,
|
||||
y: value.0.y,
|
||||
dir: value.1,
|
||||
}
|
||||
DirectionalKartesian { x: value.0.x, y: value.0.y, dir: value.1 }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Integer + Copy> Into<(Kartesian<T>, KartesianDirection)> for &DirectionalKartesian<T> {
|
||||
fn into(self) -> (Kartesian<T>, KartesianDirection) {
|
||||
(
|
||||
Kartesian {
|
||||
x: self.x,
|
||||
y: self.y,
|
||||
},
|
||||
self.dir,
|
||||
)
|
||||
(Kartesian { x: self.x, y: self.y }, self.dir)
|
||||
}
|
||||
}
|
||||
|
|
@ -40,13 +40,10 @@ impl StoneCounter {
|
|||
fn new(start_values: Vec<u64>, rounds: usize) -> StoneCounter {
|
||||
let mut cache = Vec::with_capacity(start_values.len());
|
||||
for v in start_values.iter() {
|
||||
cache.push(Stone {
|
||||
number: *v,
|
||||
left: rounds,
|
||||
});
|
||||
cache.push(Stone { number: *v, left: rounds });
|
||||
}
|
||||
StoneCounter {
|
||||
cache,
|
||||
cache: cache,
|
||||
map: HashMap::with_capacity(10_000),
|
||||
stones: 0,
|
||||
start: rounds,
|
||||
|
@ -75,10 +72,7 @@ impl StoneCounter {
|
|||
stone.left -= skip.skipped_steps;
|
||||
}
|
||||
stone.number = skip.newnumber_a;
|
||||
self.cache.push(Stone {
|
||||
number: skip.newnumber_b,
|
||||
left: stone.left,
|
||||
});
|
||||
self.cache.push(Stone { number: skip.newnumber_b, left: stone.left });
|
||||
continue;
|
||||
},
|
||||
ExtendedOption::Unset => {},
|
|
@ -108,54 +108,18 @@ mod test {
|
|||
#[test]
|
||||
fn test_safety() {
|
||||
let positions = vec![
|
||||
Kartesian {
|
||||
x: 5,
|
||||
y: 3,
|
||||
},
|
||||
Kartesian {
|
||||
x: 4,
|
||||
y: 5,
|
||||
},
|
||||
Kartesian {
|
||||
x: 0,
|
||||
y: 9,
|
||||
},
|
||||
Kartesian {
|
||||
x: 5,
|
||||
y: 4,
|
||||
},
|
||||
Kartesian {
|
||||
x: 6,
|
||||
y: 1,
|
||||
},
|
||||
Kartesian {
|
||||
x: 3,
|
||||
y: 1,
|
||||
},
|
||||
Kartesian {
|
||||
x: 0,
|
||||
y: 6,
|
||||
},
|
||||
Kartesian {
|
||||
x: 3,
|
||||
y: 2,
|
||||
},
|
||||
Kartesian {
|
||||
x: 2,
|
||||
y: 0,
|
||||
},
|
||||
Kartesian {
|
||||
x: 0,
|
||||
y: 6,
|
||||
},
|
||||
Kartesian {
|
||||
x: 5,
|
||||
y: 4,
|
||||
},
|
||||
Kartesian {
|
||||
x: 6,
|
||||
y: 6,
|
||||
},
|
||||
Kartesian { x: 5, y: 3 },
|
||||
Kartesian { x: 4, y: 5 },
|
||||
Kartesian { x: 0, y: 9 },
|
||||
Kartesian { x: 5, y: 4 },
|
||||
Kartesian { x: 6, y: 1 },
|
||||
Kartesian { x: 3, y: 1 },
|
||||
Kartesian { x: 0, y: 6 },
|
||||
Kartesian { x: 3, y: 2 },
|
||||
Kartesian { x: 2, y: 0 },
|
||||
Kartesian { x: 0, y: 6 },
|
||||
Kartesian { x: 5, y: 4 },
|
||||
Kartesian { x: 6, y: 6 },
|
||||
];
|
||||
assert_eq!(calc_safety(positions, Kartesian::new(7, 11)), (1, 3, 4, 1));
|
||||
}
|
|
@ -87,8 +87,11 @@ fn main() {
|
|||
let map = Map::from(convert_to_array::<_, _, '\n'>(DATA, line_to_char));
|
||||
//println!("Startmap: \n{}", map);
|
||||
let deer = find_character(&map, 'S');
|
||||
let best = search_end(&map, deer, KartesianDirection::East);
|
||||
println!("Best Score is: {}", best)
|
||||
let best = search_end(&map, deer, KartesianDirection::Right);
|
||||
println!(
|
||||
"Best Score is: {}",
|
||||
best
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren