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"
|
name = "2023-01"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/01.rs"
|
path = "src/bin/2023/01.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-02"
|
name = "2023-02"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/02.rs"
|
path = "src/bin/2023/02.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-03"
|
name = "2023-03"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/03.rs"
|
path = "src/bin/2023/03.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-04"
|
name = "2023-04"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/04.rs"
|
path = "src/bin/2023/04.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-05"
|
name = "2023-05"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/05.rs"
|
path = "src/bin/2023/05.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-06"
|
name = "2023-06"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/06.rs"
|
path = "src/bin/2023/06.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-07"
|
name = "2023-07"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/07.rs"
|
path = "src/bin/2023/07.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-08"
|
name = "2023-08"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/08.rs"
|
path = "src/bin/2023/08.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-09"
|
name = "2023-09"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/09.rs"
|
path = "src/bin/2023/09.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-10"
|
name = "2023-10"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/10.rs"
|
path = "src/bin/2023/10.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-11"
|
name = "2023-11"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/11.rs"
|
path = "src/bin/2023/11.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-12"
|
name = "2023-12"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/12.rs"
|
path = "src/bin/2023/12.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-13"
|
name = "2023-13"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/13.rs"
|
path = "src/bin/2023/13.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-14"
|
name = "2023-14"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/14.rs"
|
path = "src/bin/2023/14.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-15"
|
name = "2023-15"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/15.rs"
|
path = "src/bin/2023/15.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-16"
|
name = "2023-16"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/16.rs"
|
path = "src/bin/2023/16.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-17"
|
name = "2023-17"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/17.rs"
|
path = "src/bin/2023/17.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-18"
|
name = "2023-18"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/18.rs"
|
path = "src/bin/2023/18.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-19"
|
name = "2023-19"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/19.rs"
|
path = "src/bin/2023/19.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-20"
|
name = "2023-20"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/20.rs"
|
path = "src/bin/2023/20.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-21"
|
name = "2023-21"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/21.rs"
|
path = "src/bin/2023/21.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-22"
|
name = "2023-22"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/22.rs"
|
path = "src/bin/2023/22.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-23"
|
name = "2023-23"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/23.rs"
|
path = "src/bin/2023/23.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-24"
|
name = "2023-24"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/24.rs"
|
path = "src/bin/2023/24.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2023-25"
|
name = "2023-25"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2023/25.rs"
|
path = "src/bin/2023/25.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-01"
|
name = "2024-01"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/01.rs"
|
path = "src/bin/2024/01.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-02"
|
name = "2024-02"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/02.rs"
|
path = "src/bin/2024/02.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-03"
|
name = "2024-03"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/03.rs"
|
path = "src/bin/2024/03.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-04"
|
name = "2024-04"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/04.rs"
|
path = "src/bin/2024/04.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-05"
|
name = "2024-05"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/05.rs"
|
path = "src/bin/2024/05.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-06"
|
name = "2024-06"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/06.rs"
|
path = "src/bin/2024/06.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-07"
|
name = "2024-07"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/07.rs"
|
path = "src/bin/2024/07.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-08"
|
name = "2024-08"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/08.rs"
|
path = "src/bin/2024/08.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-09"
|
name = "2024-09"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/09.rs"
|
path = "src/bin/2024/09.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-10"
|
name = "2024-10"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/10.rs"
|
path = "src/bin/2024/10.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-11"
|
name = "2024-11"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/11.rs"
|
path = "src/bin/2024/11.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-12"
|
name = "2024-12"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/12.rs"
|
path = "src/bin/2024/12.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-13"
|
name = "2024-13"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/13.rs"
|
path = "src/bin/2024/13.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-14"
|
name = "2024-14"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/14.rs"
|
path = "src/bin/2024/14.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-15"
|
name = "2024-15"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/15.rs"
|
path = "src/bin/2024/15.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-16"
|
name = "2024-16"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/16.rs"
|
path = "src/bin/2024/16.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-17"
|
name = "2024-17"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/17.rs"
|
path = "src/bin/2024/17.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-18"
|
name = "2024-18"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/18.rs"
|
path = "src/bin/2024/18.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-19"
|
name = "2024-19"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/19.rs"
|
path = "src/bin/2024/19.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-20"
|
name = "2024-20"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/20.rs"
|
path = "src/bin/2024/20.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-21"
|
name = "2024-21"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/21.rs"
|
path = "src/bin/2024/21.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-22"
|
name = "2024-22"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/22.rs"
|
path = "src/bin/2024/22.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-23"
|
name = "2024-23"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/23.rs"
|
path = "src/bin/2024/23.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-24"
|
name = "2024-24"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/24.rs"
|
path = "src/bin/2024/24.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "2024-25"
|
name = "2024-25"
|
||||||
test = false
|
test = false
|
||||||
bench = false
|
bench = false
|
||||||
path = "days/2024/25.rs"
|
path = "src/bin/2024/25.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "advent_of_code"
|
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
|
SMSMSASXSS
|
||||||
SAXAMASAAA
|
SAXAMASAAA
|
||||||
MAMMMXMMMM
|
MAMMMXMMMM
|
||||||
MXMXAXMASX
|
MXMXAXMASX
|
|
@ -9,4 +9,4 @@ p=3,0 v=-1,-2
|
||||||
p=9,3 v=2,3
|
p=9,3 v=2,3
|
||||||
p=7,3 v=-1,2
|
p=7,3 v=-1,2
|
||||||
p=2,4 v=2,-3
|
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........................#
|
#S........................#
|
||||||
###########################
|
###########################
|
|
@ -1,4 +1,4 @@
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
# 16c
|
# 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
|
ok
|
||||||
}
|
}
|
||||||
fn power(&self) -> u64 {
|
fn power(&self) -> u64 {
|
||||||
let mut sack = Sack {
|
let mut sack = Sack { reds: 0, greens: 0, blues: 0 };
|
||||||
reds: 0,
|
|
||||||
greens: 0,
|
|
||||||
blues: 0,
|
|
||||||
};
|
|
||||||
for take in self.takes.clone() {
|
for take in self.takes.clone() {
|
||||||
if take.red > sack.reds {
|
if take.red > sack.reds {
|
||||||
sack.reds = take.red
|
sack.reds = take.red
|
||||||
|
@ -70,11 +66,7 @@ impl From<&str> for Round {
|
||||||
takes: Vec::<Take>::new(),
|
takes: Vec::<Take>::new(),
|
||||||
};
|
};
|
||||||
for taking in value.get(doublecolon + 1..).unwrap().split(";") {
|
for taking in value.get(doublecolon + 1..).unwrap().split(";") {
|
||||||
let mut take = Take {
|
let mut take = Take { red: 0, green: 0, blue: 0 };
|
||||||
red: 0,
|
|
||||||
green: 0,
|
|
||||||
blue: 0,
|
|
||||||
};
|
|
||||||
for color in taking.split(',').map(str::trim) {
|
for color in taking.split(',').map(str::trim) {
|
||||||
let mut i = color.splitn(2, char::is_whitespace);
|
let mut i = color.splitn(2, char::is_whitespace);
|
||||||
let amount = parsenumber(i.next().unwrap());
|
let amount = parsenumber(i.next().unwrap());
|
||||||
|
@ -96,11 +88,7 @@ fn main() {
|
||||||
for game in DATA.split('\n') {
|
for game in DATA.split('\n') {
|
||||||
gamerounds.push(game.into());
|
gamerounds.push(game.into());
|
||||||
}
|
}
|
||||||
let sack = Sack {
|
let sack = Sack { reds: 12, greens: 13, blues: 14 };
|
||||||
reds: 12,
|
|
||||||
greens: 13,
|
|
||||||
blues: 14,
|
|
||||||
};
|
|
||||||
let mut sum = 0;
|
let mut sum = 0;
|
||||||
for round in gamerounds.clone() {
|
for round in gamerounds.clone() {
|
||||||
if round.possible(sack) {
|
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>) {
|
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();
|
let mut iter = chars.iter().cloned();
|
||||||
match iter.next() {
|
match iter.next() {
|
||||||
None => list.push(TextPos {
|
None => list.push(TextPos { start: start_point, end: current_pos }),
|
||||||
start: start_point,
|
|
||||||
end: current_pos,
|
|
||||||
}),
|
|
||||||
Some(c) => match current_pos.move_dir_max(direction.vector_abs(), direction, Kartesian::maximum(data)) {
|
Some(c) => match current_pos.move_dir_max(direction.vector_abs(), direction, Kartesian::maximum(data)) {
|
||||||
None => return,
|
None => return,
|
||||||
Some(new) => {
|
Some(new) => {
|
|
@ -18,23 +18,13 @@ struct DirectionalKartesian<T: Integer> {
|
||||||
}
|
}
|
||||||
impl<T: Integer> From<(Kartesian<T>, KartesianDirection)> for DirectionalKartesian<T> {
|
impl<T: Integer> From<(Kartesian<T>, KartesianDirection)> for DirectionalKartesian<T> {
|
||||||
fn from(value: (Kartesian<T>, KartesianDirection)) -> Self {
|
fn from(value: (Kartesian<T>, KartesianDirection)) -> Self {
|
||||||
DirectionalKartesian {
|
DirectionalKartesian { x: value.0.x, y: value.0.y, dir: value.1 }
|
||||||
x: value.0.x,
|
|
||||||
y: value.0.y,
|
|
||||||
dir: value.1,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Integer + Copy> Into<(Kartesian<T>, KartesianDirection)> for &DirectionalKartesian<T> {
|
impl<T: Integer + Copy> Into<(Kartesian<T>, KartesianDirection)> for &DirectionalKartesian<T> {
|
||||||
fn into(self) -> (Kartesian<T>, KartesianDirection) {
|
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 {
|
fn new(start_values: Vec<u64>, rounds: usize) -> StoneCounter {
|
||||||
let mut cache = Vec::with_capacity(start_values.len());
|
let mut cache = Vec::with_capacity(start_values.len());
|
||||||
for v in start_values.iter() {
|
for v in start_values.iter() {
|
||||||
cache.push(Stone {
|
cache.push(Stone { number: *v, left: rounds });
|
||||||
number: *v,
|
|
||||||
left: rounds,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
StoneCounter {
|
StoneCounter {
|
||||||
cache,
|
cache: cache,
|
||||||
map: HashMap::with_capacity(10_000),
|
map: HashMap::with_capacity(10_000),
|
||||||
stones: 0,
|
stones: 0,
|
||||||
start: rounds,
|
start: rounds,
|
||||||
|
@ -75,10 +72,7 @@ impl StoneCounter {
|
||||||
stone.left -= skip.skipped_steps;
|
stone.left -= skip.skipped_steps;
|
||||||
}
|
}
|
||||||
stone.number = skip.newnumber_a;
|
stone.number = skip.newnumber_a;
|
||||||
self.cache.push(Stone {
|
self.cache.push(Stone { number: skip.newnumber_b, left: stone.left });
|
||||||
number: skip.newnumber_b,
|
|
||||||
left: stone.left,
|
|
||||||
});
|
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
ExtendedOption::Unset => {},
|
ExtendedOption::Unset => {},
|
|
@ -108,54 +108,18 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_safety() {
|
fn test_safety() {
|
||||||
let positions = vec![
|
let positions = vec![
|
||||||
Kartesian {
|
Kartesian { x: 5, y: 3 },
|
||||||
x: 5,
|
Kartesian { x: 4, y: 5 },
|
||||||
y: 3,
|
Kartesian { x: 0, y: 9 },
|
||||||
},
|
Kartesian { x: 5, y: 4 },
|
||||||
Kartesian {
|
Kartesian { x: 6, y: 1 },
|
||||||
x: 4,
|
Kartesian { x: 3, y: 1 },
|
||||||
y: 5,
|
Kartesian { x: 0, y: 6 },
|
||||||
},
|
Kartesian { x: 3, y: 2 },
|
||||||
Kartesian {
|
Kartesian { x: 2, y: 0 },
|
||||||
x: 0,
|
Kartesian { x: 0, y: 6 },
|
||||||
y: 9,
|
Kartesian { x: 5, y: 4 },
|
||||||
},
|
Kartesian { x: 6, y: 6 },
|
||||||
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));
|
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));
|
let map = Map::from(convert_to_array::<_, _, '\n'>(DATA, line_to_char));
|
||||||
//println!("Startmap: \n{}", map);
|
//println!("Startmap: \n{}", map);
|
||||||
let deer = find_character(&map, 'S');
|
let deer = find_character(&map, 'S');
|
||||||
let best = search_end(&map, deer, KartesianDirection::East);
|
let best = search_end(&map, deer, KartesianDirection::Right);
|
||||||
println!("Best Score is: {}", best)
|
println!(
|
||||||
|
"Best Score is: {}",
|
||||||
|
best
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren